Skip to content

Commit

Permalink
Merge pull request #58 from oliverheywood451/#57-update-to-release-1.…
Browse files Browse the repository at this point in the history
…0.225

update to API version 1.0.255
  • Loading branch information
oliverheywood451 authored Feb 1, 2022
2 parents f1d831d + df9922b commit 34bf954
Show file tree
Hide file tree
Showing 8 changed files with 286 additions and 32 deletions.
3 changes: 2 additions & 1 deletion codegen/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ var postFormatOperation = function (operation) {
operation["listAllParams"] = operation.allParams.filter(function (param) { return !notValidListAllParams.includes(param.name); });
operation["listByIDParams"] = operation.allParams.filter(function (param) { return !notValidListByIDParams.includes(param.name); });
operation["listArgsParams"] = operation.allParams.filter(function (param) { return !listArgsParams.includes(param.name); });
operation["hasXP"] = !operation.name.includes("Assignment") && !["ImpersonationConfig", "OpenIdConnect", "Incrementor", "SecurityProfile", "XpIndex", "Webhook", "IntegrationEvent", "SupplierBuyer", "BuyerSupplier"].includes((_c = operation.returnType) !== null && _c !== void 0 ? _c : "");
operation["hasXP"] = !operation.name.includes("Assignment") && !["ImpersonationConfig", "Locale", "OpenIdConnect", "Incrementor", "SecurityProfile", "XpIndex", "Webhook", "IntegrationEvent", "SupplierBuyer", "BuyerSupplier"].includes((_c = operation.returnType) !== null && _c !== void 0 ? _c : "");
operation["isAdvancedSearch"] = operation.allParams.some(function (param) { return param.name === "searchType"; });
operation.allParams.forEach(function (param) {
var _a, _b, _c, _d, _e;
param["listAllValue"] = (_a = listAllParamMapping[param.name]) !== null && _a !== void 0 ? _a : param.name;
Expand Down
4 changes: 3 additions & 1 deletion codegen/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ const postFormatOperation: PostFormatOperationHook = function(operation: Operati
operation["listByIDParams"] = operation.allParams.filter(param => !notValidListByIDParams.includes(param.name))
operation["listArgsParams"] = operation.allParams.filter(param => !listArgsParams.includes(param.name))

operation["hasXP"] = !operation.name.includes("Assignment") && !["ImpersonationConfig", "OpenIdConnect", "Incrementor", "SecurityProfile", "XpIndex", "Webhook", "IntegrationEvent", "SupplierBuyer", "BuyerSupplier"].includes(operation.returnType ?? "")
operation["hasXP"] = !operation.name.includes("Assignment") && !["ImpersonationConfig", "Locale", "OpenIdConnect", "Incrementor", "SecurityProfile", "XpIndex", "Webhook", "IntegrationEvent", "SupplierBuyer", "BuyerSupplier"].includes(operation.returnType ?? "")
operation["isAdvancedSearch"] = operation.allParams.some(param => param.name === "searchType");


operation.allParams.forEach(param => {
param["listAllValue"] = listAllParamMapping[param.name] ?? param.name
Expand Down
8 changes: 4 additions & 4 deletions codegen/templates/ListExtensions.cs.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ namespace OrderCloud.Catalyst
public static class ListExtensions
{
{{#resources}}{{#with this as | resource |}}{{#operations}}{{#with this as | operation |}}{{#if isList}}
public static async Task<ListPage{{#if isFacetList}}WithFacets{{else}}{{/if}}<{{operation.returnType}}>> {{operation.name}}Async(this I{{resource.id}}Resource resource, {{#listArgsParams}}{{type}} {{name}}{{#unless isRequired}} = null{{/unless}}, {{/listArgsParams}}{{#if isFacetList}}SearchArgs<{{operation.returnType}}>{{else}}IListArgs{{/if}} args = null, string accessToken = null)
public static async Task<ListPage{{#if isFacetList}}WithFacets{{else}}{{/if}}<{{operation.returnType}}>> {{operation.name}}Async(this I{{resource.id}}Resource resource, {{#listArgsParams}}{{type}} {{name}}{{#unless isRequired}} = null{{/unless}}, {{/listArgsParams}}{{#if isAdvancedSearch}}SearchArgs<{{operation.returnType}}>{{else}}IListArgs{{/if}} args = null, string accessToken = null)
{
args = args ?? new {{#if isFacetList}}SearchArgs{{else}}ListArgs{{/if}}<{{operation.returnType}}>();
args = args ?? new {{#if isAdvancedSearch}}SearchArgs{{else}}ListArgs{{/if}}<{{operation.returnType}}>();
return await resource.{{operation.name}}Async({{#allParams}}{{listArgsValue}}, {{/allParams}}accessToken);
}

{{#if operation.hasXP}}public static async Task<ListPage{{#if isFacetList}}WithFacets{{else}}{{/if}}<T>> {{operation.name}}Async<T>(this I{{resource.id}}Resource resource, {{#listArgsParams}}{{type}} {{name}}{{#unless isRequired}} = null{{/unless}}, {{/listArgsParams}}{{#if isFacetList}}SearchArgs<T>{{else}}IListArgs{{/if}} args = null, string accessToken = null)
{{#if operation.hasXP}}public static async Task<ListPage{{#if isFacetList}}WithFacets{{else}}{{/if}}<T>> {{operation.name}}Async<T>(this I{{resource.id}}Resource resource, {{#listArgsParams}}{{type}} {{name}}{{#unless isRequired}} = null{{/unless}}, {{/listArgsParams}}{{#if isAdvancedSearch}}SearchArgs<T>{{else}}IListArgs{{/if}} args = null, string accessToken = null)
where T : {{operation.returnType}}
{
args = args ?? new {{#if isFacetList}}SearchArgs{{else}}ListArgs{{/if}}<T>();
args = args ?? new {{#if isAdvancedSearch}}SearchArgs{{else}}ListArgs{{/if}}<T>();
return await resource.{{operation.name}}Async<T>({{#allParams}}{{listArgsValue}}, {{/allParams}}accessToken);
}{{/if}}{{/if}}{{/with}}{{/operations}}{{/with}}{{/resources}}
}
Expand Down
158 changes: 150 additions & 8 deletions library/OrderCloud.Catalyst/Generated/ListAllExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,50 @@ await ListAllHelper.ListBatchedAsync(async (filter) =>



public static async Task<List<Locale>> ListAllAsync(this ILocalesResource resource, object filters = null, string accessToken = null)
{
return await ListAllHelper.ListAllAsync((page, filter) =>
{
return resource.ListAsync(null, null, SORT_BY_ID, page, MAX_PAGE_SIZE, filters.AndFilter(filter), accessToken);
});
}



public static async Task ListAllAsync(this ILocalesResource resource, Func<ListPage<Locale>, Task> action, object filters = null, string accessToken = null)
{
await ListAllHelper.ListBatchedAsync(async (filter) =>
{
var result = await resource.ListAsync(null, null, SORT_BY_ID, PAGE_ONE, MAX_PAGE_SIZE, filters.AndFilter(filter), accessToken);
await action(result);
return result;
});
}



public static async Task<List<LocaleAssignment>> ListAllAssignmentsAsync(this ILocalesResource resource, string buyerID = null, string localeID = null, string userID = null, string userGroupID = null, PartyType? level = null, string accessToken = null)
{
return await ListAllHelper.ListAllAsync((page, filter) =>
{
return resource.ListAssignmentsAsync(buyerID, localeID, userID, userGroupID, level, page, MAX_PAGE_SIZE, accessToken);
});
}



public static async Task ListAllAssignmentsAsync(this ILocalesResource resource, Func<ListPage<LocaleAssignment>, Task> action, string buyerID = null, string localeID = null, string userID = null, string userGroupID = null, PartyType? level = null, string accessToken = null)
{
await ListAllHelper.ListBatchedAsync(async (filter) =>
{
var result = await resource.ListAssignmentsAsync(buyerID, localeID, userID, userGroupID, level, PAGE_ONE, MAX_PAGE_SIZE, accessToken);
await action(result);
return result;
});
}



public static async Task<List<Webhook>> ListAllAsync(this IWebhooksResource resource, object filters = null, string accessToken = null)
{
return await ListAllHelper.ListAllAsync((page, filter) =>
Expand Down Expand Up @@ -505,6 +549,28 @@ await ListAllHelper.ListBatchedAsync(async (filter) =>
});
}

public static async Task<List<BuyerSupplier>> ListAllBuyerSellersAsync(this IBuyersResource resource, string buyerID, object filters = null, string accessToken = null)
{
return await ListAllHelper.ListAllAsync((page, filter) =>
{
return resource.ListBuyerSellersAsync(buyerID, null, null, SORT_BY_ID, page, MAX_PAGE_SIZE, filters.AndFilter(filter), accessToken);
});
}



public static async Task ListAllBuyerSellersAsync(this IBuyersResource resource, Func<ListPage<BuyerSupplier>, Task> action, string buyerID, object filters = null, string accessToken = null)
{
await ListAllHelper.ListBatchedAsync(async (filter) =>
{
var result = await resource.ListBuyerSellersAsync(buyerID, null, null, SORT_BY_ID, PAGE_ONE, MAX_PAGE_SIZE, filters.AndFilter(filter), accessToken);
await action(result);
return result;
});
}



public static async Task<List<User>> ListAllAsync(this IUsersResource resource, string buyerID, string userGroupID = null, object filters = null, string accessToken = null)
{
return await ListAllHelper.ListAllAsync((page, filter) =>
Expand Down Expand Up @@ -1589,11 +1655,87 @@ await ListAllHelper.ListBatchedAsync(async (filter) =>
});
}

public static async Task<List<InventoryRecord>> ListAllAsync(this IInventoryRecordsResource resource, string productID, object filters = null, string accessToken = null)
{
return await ListAllHelper.ListAllAsync((page, filter) =>
{
return resource.ListAsync(productID, null, null, SORT_BY_ID, page, MAX_PAGE_SIZE, filters.AndFilter(filter), accessToken);
});
}

public static async Task<List<T>> ListAllAsync<T>(this IInventoryRecordsResource resource, string productID, object filters = null, string accessToken = null)
where T : InventoryRecord
{
return await ListAllHelper.ListAllAsync((page, filter) =>
{
return resource.ListAsync<T>(productID, null, null, SORT_BY_ID, page, MAX_PAGE_SIZE, filters.AndFilter(filter), accessToken);
});
}

public static async Task ListAllAsync(this IInventoryRecordsResource resource, Func<ListPage<InventoryRecord>, Task> action, string productID, object filters = null, string accessToken = null)
{
await ListAllHelper.ListBatchedAsync(async (filter) =>
{
var result = await resource.ListAsync(productID, null, null, SORT_BY_ID, PAGE_ONE, MAX_PAGE_SIZE, filters.AndFilter(filter), accessToken);
await action(result);
return result;
});
}

public static async Task ListAllAsync<T>(this IInventoryRecordsResource resource, Func<ListPage<T>, Task> action, string productID, object filters = null, string accessToken = null)
where T : InventoryRecord
{
await ListAllHelper.ListBatchedAsync(async (filter) =>
{
var result = await resource.ListAsync<T>(productID, null, null, SORT_BY_ID, PAGE_ONE, MAX_PAGE_SIZE, filters.AndFilter(filter), accessToken);
await action(result);
return result;
});
}

public static async Task<List<InventoryRecord>> ListAllVariantAsync(this IInventoryRecordsResource resource, string productID, string variantID, object filters = null, string accessToken = null)
{
return await ListAllHelper.ListAllAsync((page, filter) =>
{
return resource.ListVariantAsync(productID, variantID, null, null, SORT_BY_ID, page, MAX_PAGE_SIZE, filters.AndFilter(filter), accessToken);
});
}

public static async Task<List<T>> ListAllVariantAsync<T>(this IInventoryRecordsResource resource, string productID, string variantID, object filters = null, string accessToken = null)
where T : InventoryRecord
{
return await ListAllHelper.ListAllAsync((page, filter) =>
{
return resource.ListVariantAsync<T>(productID, variantID, null, null, SORT_BY_ID, page, MAX_PAGE_SIZE, filters.AndFilter(filter), accessToken);
});
}

public static async Task ListAllVariantAsync(this IInventoryRecordsResource resource, Func<ListPage<InventoryRecord>, Task> action, string productID, string variantID, object filters = null, string accessToken = null)
{
await ListAllHelper.ListBatchedAsync(async (filter) =>
{
var result = await resource.ListVariantAsync(productID, variantID, null, null, SORT_BY_ID, PAGE_ONE, MAX_PAGE_SIZE, filters.AndFilter(filter), accessToken);
await action(result);
return result;
});
}

public static async Task ListAllVariantAsync<T>(this IInventoryRecordsResource resource, Func<ListPage<T>, Task> action, string productID, string variantID, object filters = null, string accessToken = null)
where T : InventoryRecord
{
await ListAllHelper.ListBatchedAsync(async (filter) =>
{
var result = await resource.ListVariantAsync<T>(productID, variantID, null, null, SORT_BY_ID, PAGE_ONE, MAX_PAGE_SIZE, filters.AndFilter(filter), accessToken);
await action(result);
return result;
});
}

public static async Task<List<Order>> ListAllAsync(this IOrdersResource resource, OrderDirection direction, string buyerID = null, string supplierID = null, DateTimeOffset? from = null, DateTimeOffset? to = null, object filters = null, string accessToken = null)
{
return await ListAllHelper.ListAllAsync((page, filter) =>
{
return resource.ListAsync(direction, buyerID, supplierID, from, to, null, null, SORT_BY_ID, page, MAX_PAGE_SIZE, filters.AndFilter(filter), accessToken);
return resource.ListAsync(direction, buyerID, supplierID, from, to, null, null, SearchType.AnyTerm, SORT_BY_ID, page, MAX_PAGE_SIZE, filters.AndFilter(filter), accessToken);
});
}

Expand All @@ -1602,15 +1744,15 @@ public static async Task<List<T>> ListAllAsync<T>(this IOrdersResource resource,
{
return await ListAllHelper.ListAllAsync((page, filter) =>
{
return resource.ListAsync<T>(direction, buyerID, supplierID, from, to, null, null, SORT_BY_ID, page, MAX_PAGE_SIZE, filters.AndFilter(filter), accessToken);
return resource.ListAsync<T>(direction, buyerID, supplierID, from, to, null, null, SearchType.AnyTerm, SORT_BY_ID, page, MAX_PAGE_SIZE, filters.AndFilter(filter), accessToken);
});
}

public static async Task ListAllAsync(this IOrdersResource resource, Func<ListPage<Order>, Task> action, OrderDirection direction, string buyerID = null, string supplierID = null, DateTimeOffset? from = null, DateTimeOffset? to = null, object filters = null, string accessToken = null)
{
await ListAllHelper.ListBatchedAsync(async (filter) =>
{
var result = await resource.ListAsync(direction, buyerID, supplierID, from, to, null, null, SORT_BY_ID, PAGE_ONE, MAX_PAGE_SIZE, filters.AndFilter(filter), accessToken);
var result = await resource.ListAsync(direction, buyerID, supplierID, from, to, null, null, SearchType.AnyTerm, SORT_BY_ID, PAGE_ONE, MAX_PAGE_SIZE, filters.AndFilter(filter), accessToken);
await action(result);
return result;
});
Expand All @@ -1621,7 +1763,7 @@ public static async Task ListAllAsync<T>(this IOrdersResource resource, Func<Lis
{
await ListAllHelper.ListBatchedAsync(async (filter) =>
{
var result = await resource.ListAsync<T>(direction, buyerID, supplierID, from, to, null, null, SORT_BY_ID, PAGE_ONE, MAX_PAGE_SIZE, filters.AndFilter(filter), accessToken);
var result = await resource.ListAsync<T>(direction, buyerID, supplierID, from, to, null, null, SearchType.AnyTerm, SORT_BY_ID, PAGE_ONE, MAX_PAGE_SIZE, filters.AndFilter(filter), accessToken);
await action(result);
return result;
});
Expand Down Expand Up @@ -2185,7 +2327,7 @@ public static async Task<List<Order>> ListAllOrdersAsync(this IMeResource resour
{
return await ListAllHelper.ListAllAsync((page, filter) =>
{
return resource.ListOrdersAsync(from, to, null, null, SORT_BY_ID, page, MAX_PAGE_SIZE, filters.AndFilter(filter), accessToken);
return resource.ListOrdersAsync(from, to, null, null, SearchType.AnyTerm, SORT_BY_ID, page, MAX_PAGE_SIZE, filters.AndFilter(filter), accessToken);
});
}

Expand All @@ -2194,15 +2336,15 @@ public static async Task<List<T>> ListAllOrdersAsync<T>(this IMeResource resourc
{
return await ListAllHelper.ListAllAsync((page, filter) =>
{
return resource.ListOrdersAsync<T>(from, to, null, null, SORT_BY_ID, page, MAX_PAGE_SIZE, filters.AndFilter(filter), accessToken);
return resource.ListOrdersAsync<T>(from, to, null, null, SearchType.AnyTerm, SORT_BY_ID, page, MAX_PAGE_SIZE, filters.AndFilter(filter), accessToken);
});
}

public static async Task ListAllOrdersAsync(this IMeResource resource, Func<ListPage<Order>, Task> action, DateTimeOffset? from = null, DateTimeOffset? to = null, object filters = null, string accessToken = null)
{
await ListAllHelper.ListBatchedAsync(async (filter) =>
{
var result = await resource.ListOrdersAsync(from, to, null, null, SORT_BY_ID, PAGE_ONE, MAX_PAGE_SIZE, filters.AndFilter(filter), accessToken);
var result = await resource.ListOrdersAsync(from, to, null, null, SearchType.AnyTerm, SORT_BY_ID, PAGE_ONE, MAX_PAGE_SIZE, filters.AndFilter(filter), accessToken);
await action(result);
return result;
});
Expand All @@ -2213,7 +2355,7 @@ public static async Task ListAllOrdersAsync<T>(this IMeResource resource, Func<L
{
await ListAllHelper.ListBatchedAsync(async (filter) =>
{
var result = await resource.ListOrdersAsync<T>(from, to, null, null, SORT_BY_ID, PAGE_ONE, MAX_PAGE_SIZE, filters.AndFilter(filter), accessToken);
var result = await resource.ListOrdersAsync<T>(from, to, null, null, SearchType.AnyTerm, SORT_BY_ID, PAGE_ONE, MAX_PAGE_SIZE, filters.AndFilter(filter), accessToken);
await action(result);
return result;
});
Expand Down
Loading

0 comments on commit 34bf954

Please sign in to comment.