Skip to content

Enhancement Idea - Reduce number of generic parameters in models #78

@oliverheywood451

Description

@oliverheywood451

This is a minor enhancement idea. If you look at models in the C# SDK, type parameters are handled slightly better (IMHO). OrderWorksheet is a good comparison because its so complex

	public class OrderWorksheet<TOrder, TLineItems, TOrderPromotions, TShipEstimateResponse, TOrderCalculateResponse, TOrderSubmitResponse, TOrderSubmitForApprovalResponse, TOrderApprovedResponse> : OrderWorksheet
		where TOrder : Order
		where TLineItems : LineItem
		where TOrderPromotions : OrderPromotion
		where TShipEstimateResponse : ShipEstimateResponse
		where TOrderCalculateResponse : OrderCalculateResponse
		where TOrderSubmitResponse : OrderSubmitResponse
		where TOrderSubmitForApprovalResponse : OrderSubmitForApprovalResponse
		where TOrderApprovedResponse : OrderApprovedResponse
	{
              ....
        }
export interface OrderWorksheet<TFromUserXp = any, TBillingAddressXp = any, TOrderXp = any, TProductXp = any, TVariantXp = any, TShippingAddressXp = any, TShipFromAddressXp = any, TLineItemsXp = any, TOrderPromotionsXp = any, TShipEstimatesXp = any, TShipEstimateResponseXp = any, TOrderCalculateResponseXp = any, TOrderSubmitResponseXp = any, TOrderSubmitForApprovalResponseXp = any, TOrderApprovedResponseXp = any> {
    Order?: Order<TOrderXp,TFromUserXp,TBillingAddressXp>
    LineItems?: LineItem<TLineItemsXp,TProductXp,TVariantXp,TShippingAddressXp,TShipFromAddressXp>[]
    OrderPromotions?: OrderPromotion<TOrderPromotionsXp>[]
    ShipEstimateResponse?: ShipEstimateResponse<TShipEstimateResponseXp,TShipEstimatesXp>
    OrderCalculateResponse?: OrderCalculateResponse<TOrderCalculateResponseXp>
    OrderSubmitResponse?: OrderSubmitResponse<TOrderSubmitResponseXp>
    OrderSubmitForApprovalResponse?: OrderSubmitForApprovalResponse<TOrderSubmitForApprovalResponseXp>
    OrderApprovedResponse?: OrderApprovedResponse<TOrderApprovedResponseXp>
}

In the C# sdk types are expected that extend the SDK models like Order and LineItem. In the JS sdk types are expected that hold the xp fields. This means there are more type arguments. The C# method is less verbose in the sdk code and in the client project code.

It also does require the creation of models like interface MyOrderPromotion extends OrderPromotion<MyOrderPromotionsXp> { }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions