Skip to content

Update generated SDKs #428

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,44 +10,52 @@ public static class ResponseExtensions
/**
* Tries to access the first element of the result list.
* Use case: query by slug which should contain zero or one element in the result list.
*/
static T? Head<T>(this IResourcePagedQueryResponse<T> response) {
*/
static T? Head<T>(this IResourcePagedQueryResponse<T> response)
{
return response.Results.FirstOrDefault();
}

/**
* Calculates the page number of the result, the pages are indexed staring 0, which means that {@code getPageIndex()}
* returns a value in [0,n) , given 'n' is the total number of pages
*/
static long PageIndex<T>(this IResourcePagedQueryResponse<T> response) {
if (response.Total == null || response.Limit == 0) {
static long PageIndex<T>(this IResourcePagedQueryResponse<T> response)
{
if (response.Total == null || response.Limit == 0)
{
throw new ArgumentException("Can only be used if the limit & total are known and limit is non-zero.");
}
return (long) Math.Floor(response.Offset / Convert.ToDecimal(response.Limit));
return (long)Math.Floor(response.Offset / Convert.ToDecimal(response.Limit));
}

/**
* Calculates the total number of pages matching the request.
*/
static long TotalPages<T>(this IResourcePagedQueryResponse<T> response) {
if (response.Total == null || response.Limit == 0) {
static long TotalPages<T>(this IResourcePagedQueryResponse<T> response)
{
if (response.Total == null || response.Limit == 0)
{
throw new ArgumentException("Can only be used if the limit & total are known and limit is non-zero.");
}
return (long) Math.Ceiling((response.Total ?? 0) / Convert.ToDecimal(response.Limit));
return (long)Math.Ceiling((response.Total ?? 0) / Convert.ToDecimal(response.Limit));
}

/**
* Checks if this is the first page of a result.
*/
static bool IsFirst<T>(this IResourcePagedQueryResponse<T> response) {
static bool IsFirst<T>(this IResourcePagedQueryResponse<T> response)
{
return response.Offset == 0;
}

/**
* Checks if it is the last possible page.
*/
static bool IsLast<T>(this IResourcePagedQueryResponse<T> response) {
if (response.Total == null) {
static bool IsLast<T>(this IResourcePagedQueryResponse<T> response)
{
if (response.Total == null)
{
throw new ArgumentException("Can only be used if the offset & total are known.");
}
//currently counting the total amount is performed in a second database call, so it is possible
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace commercetools.Sdk.Api.Models.ApiClients;

public partial interface IApiClientPagedQueryResponse: IResourcePagedQueryResponse<IApiClient>
public partial interface IApiClientPagedQueryResponse : IResourcePagedQueryResponse<IApiClient>
{

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace commercetools.Sdk.Api.Models.ApprovalFlows;

public partial interface IApprovalFlowPagedQueryResponse: IResourcePagedQueryResponse<IApprovalFlow>
public partial interface IApprovalFlowPagedQueryResponse : IResourcePagedQueryResponse<IApprovalFlow>
{

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace commercetools.Sdk.Api.Models.ApprovalRules;

public partial interface IApprovalRulePagedQueryResponse: IResourcePagedQueryResponse<IApprovalRule>
public partial interface IApprovalRulePagedQueryResponse : IResourcePagedQueryResponse<IApprovalRule>
{

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace commercetools.Sdk.Api.Models.AssociateRoles;

public partial interface IAssociateRolePagedQueryResponse: IResourcePagedQueryResponse<IAssociateRole>
public partial interface IAssociateRolePagedQueryResponse : IResourcePagedQueryResponse<IAssociateRole>
{

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace commercetools.Sdk.Api.Models.AttributeGroups;

public partial interface IAttributeGroupPagedQueryResponse: IResourcePagedQueryResponse<IAttributeGroup>
public partial interface IAttributeGroupPagedQueryResponse : IResourcePagedQueryResponse<IAttributeGroup>
{

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace commercetools.Sdk.Api.Models.BusinessUnits;

public partial interface IBusinessUnitPagedQueryResponse: IResourcePagedQueryResponse<IBusinessUnit>
public partial interface IBusinessUnitPagedQueryResponse : IResourcePagedQueryResponse<IBusinessUnit>
{

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace commercetools.Sdk.Api.Models.CartDiscounts;

public partial interface ICartDiscountPagedQueryResponse: IResourcePagedQueryResponse<ICartDiscount>
public partial interface ICartDiscountPagedQueryResponse : IResourcePagedQueryResponse<ICartDiscount>
{

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace commercetools.Sdk.Api.Models.Carts;

public partial interface ICartPagedQueryResponse: IResourcePagedQueryResponse<ICart>
public partial interface ICartPagedQueryResponse : IResourcePagedQueryResponse<ICart>
{

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace commercetools.Sdk.Api.Models.Categories;

public partial interface ICategoryPagedQueryResponse: IResourcePagedQueryResponse<ICategory>
public partial interface ICategoryPagedQueryResponse : IResourcePagedQueryResponse<ICategory>
{

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace commercetools.Sdk.Api.Models.Channels;

public partial interface IChannelPagedQueryResponse: IResourcePagedQueryResponse<IChannel>
public partial interface IChannelPagedQueryResponse : IResourcePagedQueryResponse<IChannel>
{

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace commercetools.Sdk.Api.Models.CustomObjects;

public partial interface ICustomObjectPagedQueryResponse: IResourcePagedQueryResponse<ICustomObject>
public partial interface ICustomObjectPagedQueryResponse : IResourcePagedQueryResponse<ICustomObject>
{

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace commercetools.Sdk.Api.Models.CustomerGroups;

public partial interface ICustomerGroupPagedQueryResponse: IResourcePagedQueryResponse<ICustomerGroup>
public partial interface ICustomerGroupPagedQueryResponse : IResourcePagedQueryResponse<ICustomerGroup>
{

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace commercetools.Sdk.Api.Models.Customers;

public partial interface ICustomerPagedQueryResponse: IResourcePagedQueryResponse<ICustomer>
public partial interface ICustomerPagedQueryResponse : IResourcePagedQueryResponse<ICustomer>
{

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace commercetools.Sdk.Api.Models.DiscountCodes;

public partial interface IDiscountCodePagedQueryResponse: IResourcePagedQueryResponse<IDiscountCode>
public partial interface IDiscountCodePagedQueryResponse : IResourcePagedQueryResponse<IDiscountCode>
{

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace commercetools.Sdk.Api.Models.Extensions;

public partial interface IExtensionPagedQueryResponse: IResourcePagedQueryResponse<IExtension>
public partial interface IExtensionPagedQueryResponse : IResourcePagedQueryResponse<IExtension>
{

}
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using System.Collections.Generic;
using System.Linq;

namespace commercetools.Sdk.Api.Models;

public interface IResourcePageableQueryResponse<T>: IResourceQueryResponse<T>
public interface IResourcePageableQueryResponse<T> : IResourceQueryResponse<T>
{
public long? Limit { get; set; }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using System.Collections.Generic;
using System.Linq;

namespace commercetools.Sdk.Api.Models;

public interface IResourcePagedQueryResponse<T>: IResourceQueryResponse<T>
public interface IResourcePagedQueryResponse<T> : IResourceQueryResponse<T>
{
public long Limit { get; set; }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace commercetools.Sdk.Api.Models.Inventories;

public partial interface IInventoryPagedQueryResponse: IResourcePagedQueryResponse<IInventoryEntry>
public partial interface IInventoryPagedQueryResponse : IResourcePagedQueryResponse<IInventoryEntry>
{

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace commercetools.Sdk.Api.Models.Messages;

public partial interface IMessagePagedQueryResponse: IResourcePagedQueryResponse<IMessage>
public partial interface IMessagePagedQueryResponse : IResourcePagedQueryResponse<IMessage>
{

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace commercetools.Sdk.Api.Models.OrderEdits;

public partial interface IOrderEditPagedQueryResponse: IResourcePagedQueryResponse<IOrderEdit>
public partial interface IOrderEditPagedQueryResponse : IResourcePagedQueryResponse<IOrderEdit>
{

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace commercetools.Sdk.Api.Models.Orders;

public partial interface IOrderPagedQueryResponse: IResourcePagedQueryResponse<IOrder>
public partial interface IOrderPagedQueryResponse : IResourcePagedQueryResponse<IOrder>
{

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace commercetools.Sdk.Api.Models.Payments;

public partial interface IPaymentPagedQueryResponse: IResourcePagedQueryResponse<IPayment>
public partial interface IPaymentPagedQueryResponse : IResourcePagedQueryResponse<IPayment>
{

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace commercetools.Sdk.Api.Models.ProductDiscounts;

public partial interface IProductDiscountPagedQueryResponse: IResourcePagedQueryResponse<IProductDiscount>
public partial interface IProductDiscountPagedQueryResponse : IResourcePagedQueryResponse<IProductDiscount>
{

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace commercetools.Sdk.Api.Models.ProductSelections;

public partial interface IProductSelectionPagedQueryResponse: IResourcePagedQueryResponse<IProductSelection>
public partial interface IProductSelectionPagedQueryResponse : IResourcePagedQueryResponse<IProductSelection>
{

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using commercetools.Sdk.Api.Models.Products;

namespace commercetools.Sdk.Api.Models.ProductTailorings;

public partial interface IProductTailoringPagedQueryResponse: IResourcePagedQueryResponse<IProductTailoring>
public partial interface IProductTailoringPagedQueryResponse : IResourcePagedQueryResponse<IProductTailoring>
{

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace commercetools.Sdk.Api.Models.ProductTypes;

public partial interface IProductTypePagedQueryResponse: IResourcePagedQueryResponse<IProductType>
public partial interface IProductTypePagedQueryResponse : IResourcePagedQueryResponse<IProductType>
{

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace commercetools.Sdk.Api.Models.Products;

public partial interface IProductPagedQueryResponse: IResourcePagedQueryResponse<IProduct>
public partial interface IProductPagedQueryResponse : IResourcePagedQueryResponse<IProduct>
{

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace commercetools.Sdk.Api.Models.Products;

public partial interface IProductProjectionPagedQueryResponse: IResourcePagedQueryResponse<IProductProjection>
public partial interface IProductProjectionPagedQueryResponse : IResourcePagedQueryResponse<IProductProjection>
{

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace commercetools.Sdk.Api.Models.QuoteRequests;

public partial interface IQuoteRequestPagedQueryResponse: IResourcePagedQueryResponse<IQuoteRequest>
public partial interface IQuoteRequestPagedQueryResponse : IResourcePagedQueryResponse<IQuoteRequest>
{

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace commercetools.Sdk.Api.Models.Quotes;

public partial interface IQuotePagedQueryResponse: IResourcePagedQueryResponse<IQuote>
public partial interface IQuotePagedQueryResponse : IResourcePagedQueryResponse<IQuote>
{

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace commercetools.Sdk.Api.Models.Reviews;

public partial interface IReviewPagedQueryResponse: IResourcePagedQueryResponse<IReview>
public partial interface IReviewPagedQueryResponse : IResourcePagedQueryResponse<IReview>
{

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace commercetools.Sdk.Api.Models.ShippingMethods;

public partial interface IShippingMethodPagedQueryResponse: IResourcePageableQueryResponse<IShippingMethod>
public partial interface IShippingMethodPagedQueryResponse : IResourcePageableQueryResponse<IShippingMethod>
{

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace commercetools.Sdk.Api.Models.ShoppingLists;

public partial interface IShoppingListPagedQueryResponse: IResourcePagedQueryResponse<IShoppingList>
public partial interface IShoppingListPagedQueryResponse : IResourcePagedQueryResponse<IShoppingList>
{

}
Loading
Loading