@commercelayer/sdk 5.0.0-beta.10 → 5.0.0-beta.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/lib/cjs/api.d.ts +10 -5
  2. package/lib/cjs/api.js +17 -2
  3. package/lib/cjs/commercelayer.d.ts +7 -2
  4. package/lib/cjs/commercelayer.js +6 -1
  5. package/lib/cjs/model.d.ts +6 -1
  6. package/lib/cjs/resources/fixed_price_promotions.d.ts +3 -3
  7. package/lib/cjs/resources/fixed_price_promotions.js +4 -4
  8. package/lib/cjs/resources/free_gift_promotions.d.ts +3 -3
  9. package/lib/cjs/resources/free_gift_promotions.js +4 -4
  10. package/lib/cjs/resources/free_shipping_promotions.d.ts +3 -0
  11. package/lib/cjs/resources/free_shipping_promotions.js +4 -0
  12. package/lib/cjs/resources/line_items.d.ts +3 -0
  13. package/lib/cjs/resources/markets.d.ts +8 -0
  14. package/lib/cjs/resources/markets.js +4 -0
  15. package/lib/cjs/resources/order_copies.d.ts +11 -9
  16. package/lib/cjs/resources/order_copies.js +7 -4
  17. package/lib/cjs/resources/order_factories.d.ts +33 -0
  18. package/lib/cjs/resources/order_factories.js +28 -0
  19. package/lib/cjs/resources/order_subscription_items.d.ts +60 -0
  20. package/lib/cjs/resources/order_subscription_items.js +29 -0
  21. package/lib/cjs/resources/order_subscriptions.d.ts +25 -3
  22. package/lib/cjs/resources/order_subscriptions.js +18 -2
  23. package/lib/cjs/resources/orders.d.ts +9 -1
  24. package/lib/cjs/resources/orders.js +8 -0
  25. package/lib/cjs/resources/percentage_discount_promotions.d.ts +3 -3
  26. package/lib/cjs/resources/percentage_discount_promotions.js +4 -4
  27. package/lib/cjs/resources/price_frequency_tiers.d.ts +49 -0
  28. package/lib/cjs/resources/price_frequency_tiers.js +37 -0
  29. package/lib/cjs/resources/price_volume_tiers.d.ts +3 -0
  30. package/lib/cjs/resources/price_volume_tiers.js +4 -0
  31. package/lib/cjs/resources/prices.d.ts +3 -0
  32. package/lib/cjs/resources/prices.js +4 -0
  33. package/lib/cjs/resources/promotions.d.ts +3 -0
  34. package/lib/cjs/resources/promotions.js +4 -0
  35. package/lib/cjs/resources/recurring_order_copies.d.ts +52 -0
  36. package/lib/cjs/resources/recurring_order_copies.js +41 -0
  37. package/lib/cjs/resources/subscription_models.d.ts +48 -0
  38. package/lib/cjs/resources/subscription_models.js +37 -0
  39. package/lib/esm/api.d.ts +10 -5
  40. package/lib/esm/api.js +10 -0
  41. package/lib/esm/commercelayer.d.ts +7 -2
  42. package/lib/esm/commercelayer.js +6 -1
  43. package/lib/esm/model.d.ts +6 -1
  44. package/lib/esm/resources/fixed_price_promotions.d.ts +3 -3
  45. package/lib/esm/resources/fixed_price_promotions.js +4 -4
  46. package/lib/esm/resources/free_gift_promotions.d.ts +3 -3
  47. package/lib/esm/resources/free_gift_promotions.js +4 -4
  48. package/lib/esm/resources/free_shipping_promotions.d.ts +3 -0
  49. package/lib/esm/resources/free_shipping_promotions.js +4 -0
  50. package/lib/esm/resources/line_items.d.ts +3 -0
  51. package/lib/esm/resources/markets.d.ts +8 -0
  52. package/lib/esm/resources/markets.js +4 -0
  53. package/lib/esm/resources/order_copies.d.ts +11 -9
  54. package/lib/esm/resources/order_copies.js +7 -4
  55. package/lib/esm/resources/order_factories.d.ts +33 -0
  56. package/lib/esm/resources/order_factories.js +26 -0
  57. package/lib/esm/resources/order_subscription_items.d.ts +60 -0
  58. package/lib/esm/resources/order_subscription_items.js +27 -0
  59. package/lib/esm/resources/order_subscriptions.d.ts +25 -3
  60. package/lib/esm/resources/order_subscriptions.js +18 -2
  61. package/lib/esm/resources/orders.d.ts +9 -1
  62. package/lib/esm/resources/orders.js +8 -0
  63. package/lib/esm/resources/percentage_discount_promotions.d.ts +3 -3
  64. package/lib/esm/resources/percentage_discount_promotions.js +4 -4
  65. package/lib/esm/resources/price_frequency_tiers.d.ts +49 -0
  66. package/lib/esm/resources/price_frequency_tiers.js +35 -0
  67. package/lib/esm/resources/price_volume_tiers.d.ts +3 -0
  68. package/lib/esm/resources/price_volume_tiers.js +4 -0
  69. package/lib/esm/resources/prices.d.ts +3 -0
  70. package/lib/esm/resources/prices.js +4 -0
  71. package/lib/esm/resources/promotions.d.ts +3 -0
  72. package/lib/esm/resources/promotions.js +4 -0
  73. package/lib/esm/resources/recurring_order_copies.d.ts +52 -0
  74. package/lib/esm/resources/recurring_order_copies.js +39 -0
  75. package/lib/esm/resources/subscription_models.d.ts +48 -0
  76. package/lib/esm/resources/subscription_models.js +35 -0
  77. package/lib/tsconfig.esm.tsbuildinfo +1 -1
  78. package/lib/tsconfig.tsbuildinfo +1 -1
  79. package/package.json +1 -1
@@ -29,6 +29,10 @@ class FreeGiftPromotions extends ApiResource {
29
29
  const _freeGiftPromotionId = freeGiftPromotionId.id || freeGiftPromotionId;
30
30
  return this.resources.fetch({ type: 'attachments' }, `free_gift_promotions/${_freeGiftPromotionId}/attachments`, params, options);
31
31
  }
32
+ async events(freeGiftPromotionId, params, options) {
33
+ const _freeGiftPromotionId = freeGiftPromotionId.id || freeGiftPromotionId;
34
+ return this.resources.fetch({ type: 'events' }, `free_gift_promotions/${_freeGiftPromotionId}/events`, params, options);
35
+ }
32
36
  async sku_list(freeGiftPromotionId, params, options) {
33
37
  const _freeGiftPromotionId = freeGiftPromotionId.id || freeGiftPromotionId;
34
38
  return this.resources.fetch({ type: 'sku_lists' }, `free_gift_promotions/${_freeGiftPromotionId}/sku_list`, params, options);
@@ -37,10 +41,6 @@ class FreeGiftPromotions extends ApiResource {
37
41
  const _freeGiftPromotionId = freeGiftPromotionId.id || freeGiftPromotionId;
38
42
  return this.resources.fetch({ type: 'skus' }, `free_gift_promotions/${_freeGiftPromotionId}/skus`, params, options);
39
43
  }
40
- async events(freeGiftPromotionId, params, options) {
41
- const _freeGiftPromotionId = freeGiftPromotionId.id || freeGiftPromotionId;
42
- return this.resources.fetch({ type: 'events' }, `free_gift_promotions/${_freeGiftPromotionId}/events`, params, options);
43
- }
44
44
  isFreeGiftPromotion(resource) {
45
45
  return resource.type && (resource.type === FreeGiftPromotions.TYPE);
46
46
  }
@@ -6,6 +6,7 @@ import type { OrderAmountPromotionRule, OrderAmountPromotionRuleType } from './o
6
6
  import type { SkuListPromotionRule, SkuListPromotionRuleType } from './sku_list_promotion_rules';
7
7
  import type { CouponCodesPromotionRule, CouponCodesPromotionRuleType } from './coupon_codes_promotion_rules';
8
8
  import type { Attachment } from './attachments';
9
+ import type { Event } from './events';
9
10
  type FreeShippingPromotionType = 'free_shipping_promotions';
10
11
  type FreeShippingPromotionRel = ResourceRel & {
11
12
  type: FreeShippingPromotionType;
@@ -40,6 +41,7 @@ interface FreeShippingPromotion extends Resource {
40
41
  sku_list_promotion_rule?: SkuListPromotionRule | null;
41
42
  coupon_codes_promotion_rule?: CouponCodesPromotionRule | null;
42
43
  attachments?: Attachment[] | null;
44
+ events?: Event[] | null;
43
45
  }
44
46
  interface FreeShippingPromotionCreate extends ResourceCreate {
45
47
  name: string;
@@ -75,6 +77,7 @@ declare class FreeShippingPromotions extends ApiResource<FreeShippingPromotion>
75
77
  sku_list_promotion_rule(freeShippingPromotionId: string | FreeShippingPromotion, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<SkuListPromotionRule>;
76
78
  coupon_codes_promotion_rule(freeShippingPromotionId: string | FreeShippingPromotion, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<CouponCodesPromotionRule>;
77
79
  attachments(freeShippingPromotionId: string | FreeShippingPromotion, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Attachment>>;
80
+ events(freeShippingPromotionId: string | FreeShippingPromotion, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Event>>;
78
81
  isFreeShippingPromotion(resource: any): resource is FreeShippingPromotion;
79
82
  relationship(id: string | ResourceId | null): FreeShippingPromotionRel;
80
83
  type(): FreeShippingPromotionType;
@@ -29,6 +29,10 @@ class FreeShippingPromotions extends ApiResource {
29
29
  const _freeShippingPromotionId = freeShippingPromotionId.id || freeShippingPromotionId;
30
30
  return this.resources.fetch({ type: 'attachments' }, `free_shipping_promotions/${_freeShippingPromotionId}/attachments`, params, options);
31
31
  }
32
+ async events(freeShippingPromotionId, params, options) {
33
+ const _freeShippingPromotionId = freeShippingPromotionId.id || freeShippingPromotionId;
34
+ return this.resources.fetch({ type: 'events' }, `free_shipping_promotions/${_freeShippingPromotionId}/events`, params, options);
35
+ }
32
36
  isFreeShippingPromotion(resource) {
33
37
  return resource.type && (resource.type === FreeShippingPromotions.TYPE);
34
38
  }
@@ -78,6 +78,7 @@ interface LineItem extends Resource {
78
78
  tax_rate?: number | null;
79
79
  tax_breakdown?: object | null;
80
80
  item_type?: 'sku' | 'bundle' | 'shipment' | 'payment_method' | 'adjustment' | 'gift_card' | 'percentage_discount_promotion' | 'free_shipping_promotion' | 'free_gift_promotion' | 'fixed_price_promotion' | 'external_promotion' | 'fixed_amount_promotion' | null;
81
+ frequency?: string | null;
81
82
  order?: Order | null;
82
83
  item?: Adjustment | Bundle | ExternalPromotion | FixedAmountPromotion | FreeShippingPromotion | GiftCard | PaymentMethod | PercentageDiscountPromotion | Shipment | Sku | null;
83
84
  line_item_options?: LineItemOption[] | null;
@@ -98,6 +99,7 @@ interface LineItemCreate extends ResourceCreate {
98
99
  name?: string | null;
99
100
  image_url?: string | null;
100
101
  item_type?: 'sku' | 'bundle' | 'shipment' | 'payment_method' | 'adjustment' | 'gift_card' | 'percentage_discount_promotion' | 'free_shipping_promotion' | 'free_gift_promotion' | 'fixed_price_promotion' | 'external_promotion' | 'fixed_amount_promotion' | null;
102
+ frequency?: string | null;
101
103
  order: OrderRel;
102
104
  item?: AdjustmentRel | BundleRel | ExternalPromotionRel | FixedAmountPromotionRel | FreeShippingPromotionRel | GiftCardRel | PaymentMethodRel | PercentageDiscountPromotionRel | ShipmentRel | SkuRel | null;
103
105
  }
@@ -108,6 +110,7 @@ interface LineItemUpdate extends ResourceUpdate {
108
110
  _external_price?: boolean | null;
109
111
  name?: string | null;
110
112
  image_url?: string | null;
113
+ frequency?: string | null;
111
114
  }
112
115
  declare class LineItems extends ApiResource<LineItem> {
113
116
  static readonly TYPE: LineItemType;
@@ -3,6 +3,7 @@ import type { QueryParamsRetrieve, QueryParamsList } from '../query';
3
3
  import type { Merchant, MerchantType } from './merchants';
4
4
  import type { PriceList, PriceListType } from './price_lists';
5
5
  import type { InventoryModel, InventoryModelType } from './inventory_models';
6
+ import type { SubscriptionModel, SubscriptionModelType } from './subscription_models';
6
7
  import type { TaxCalculator, TaxCalculatorType } from './tax_calculators';
7
8
  import type { CustomerGroup, CustomerGroupType } from './customer_groups';
8
9
  import type { Attachment } from './attachments';
@@ -19,6 +20,9 @@ type PriceListRel = ResourceRel & {
19
20
  type InventoryModelRel = ResourceRel & {
20
21
  type: InventoryModelType;
21
22
  };
23
+ type SubscriptionModelRel = ResourceRel & {
24
+ type: SubscriptionModelType;
25
+ };
22
26
  type TaxCalculatorRel = ResourceRel & {
23
27
  type: TaxCalculatorType;
24
28
  };
@@ -39,6 +43,7 @@ interface Market extends Resource {
39
43
  merchant?: Merchant | null;
40
44
  price_list?: PriceList | null;
41
45
  inventory_model?: InventoryModel | null;
46
+ subscription_model?: SubscriptionModel | null;
42
47
  tax_calculator?: TaxCalculator | null;
43
48
  customer_group?: CustomerGroup | null;
44
49
  attachments?: Attachment[] | null;
@@ -52,6 +57,7 @@ interface MarketCreate extends ResourceCreate {
52
57
  merchant: MerchantRel;
53
58
  price_list: PriceListRel;
54
59
  inventory_model: InventoryModelRel;
60
+ subscription_model?: SubscriptionModelRel | null;
55
61
  tax_calculator?: TaxCalculatorRel | null;
56
62
  customer_group?: CustomerGroupRel | null;
57
63
  }
@@ -66,6 +72,7 @@ interface MarketUpdate extends ResourceUpdate {
66
72
  merchant?: MerchantRel | null;
67
73
  price_list?: PriceListRel | null;
68
74
  inventory_model?: InventoryModelRel | null;
75
+ subscription_model?: SubscriptionModelRel | null;
69
76
  tax_calculator?: TaxCalculatorRel | null;
70
77
  customer_group?: CustomerGroupRel | null;
71
78
  }
@@ -77,6 +84,7 @@ declare class Markets extends ApiResource<Market> {
77
84
  merchant(marketId: string | Market, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Merchant>;
78
85
  price_list(marketId: string | Market, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<PriceList>;
79
86
  inventory_model(marketId: string | Market, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<InventoryModel>;
87
+ subscription_model(marketId: string | Market, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<SubscriptionModel>;
80
88
  tax_calculator(marketId: string | Market, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<TaxCalculator>;
81
89
  customer_group(marketId: string | Market, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<CustomerGroup>;
82
90
  attachments(marketId: string | Market, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Attachment>>;
@@ -21,6 +21,10 @@ class Markets extends ApiResource {
21
21
  const _marketId = marketId.id || marketId;
22
22
  return this.resources.fetch({ type: 'inventory_models' }, `markets/${_marketId}/inventory_model`, params, options);
23
23
  }
24
+ async subscription_model(marketId, params, options) {
25
+ const _marketId = marketId.id || marketId;
26
+ return this.resources.fetch({ type: 'subscription_models' }, `markets/${_marketId}/subscription_model`, params, options);
27
+ }
24
28
  async tax_calculator(marketId, params, options) {
25
29
  const _marketId = marketId.id || marketId;
26
30
  return this.resources.fetch({ type: 'tax_calculators' }, `markets/${_marketId}/tax_calculator`, params, options);
@@ -1,8 +1,8 @@
1
- import { ApiResource, Resource, ResourceCreate, ResourceId, ResourcesConfig, ResourceRel, ListResponse } from '../resource';
1
+ import { ApiResource, Resource, ResourceCreate, ResourceUpdate, ResourceId, ResourcesConfig, ResourceRel, ListResponse } from '../resource';
2
2
  import type { QueryParamsRetrieve, QueryParamsList } from '../query';
3
3
  import type { Order, OrderType } from './orders';
4
- import type { OrderSubscription } from './order_subscriptions';
5
4
  import type { Event } from './events';
5
+ import type { OrderSubscription } from './order_subscriptions';
6
6
  type OrderCopyType = 'order_copies';
7
7
  type OrderCopyRel = ResourceRel & {
8
8
  type: OrderCopyType;
@@ -16,33 +16,35 @@ interface OrderCopy extends Resource {
16
16
  started_at?: string | null;
17
17
  completed_at?: string | null;
18
18
  failed_at?: string | null;
19
- place_target_order?: boolean | null;
20
- cancel_source_order?: boolean | null;
21
- reuse_wallet?: boolean | null;
22
19
  errors_log?: object | null;
23
20
  errors_count?: number | null;
21
+ place_target_order?: boolean | null;
22
+ reuse_wallet?: boolean | null;
23
+ cancel_source_order?: boolean | null;
24
24
  source_order?: Order | null;
25
25
  target_order?: Order | null;
26
- order_subscription?: OrderSubscription | null;
27
26
  events?: Event[] | null;
27
+ order_subscription?: OrderSubscription | null;
28
28
  }
29
29
  interface OrderCopyCreate extends ResourceCreate {
30
30
  place_target_order?: boolean | null;
31
- cancel_source_order?: boolean | null;
32
31
  reuse_wallet?: boolean | null;
32
+ cancel_source_order?: boolean | null;
33
33
  source_order: OrderRel;
34
34
  }
35
+ type OrderCopyUpdate = ResourceUpdate;
35
36
  declare class OrderCopies extends ApiResource<OrderCopy> {
36
37
  static readonly TYPE: OrderCopyType;
37
38
  create(resource: OrderCopyCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<OrderCopy>;
39
+ update(resource: OrderCopyUpdate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<OrderCopy>;
38
40
  delete(id: string | ResourceId, options?: ResourcesConfig): Promise<void>;
39
41
  source_order(orderCopyId: string | OrderCopy, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Order>;
40
42
  target_order(orderCopyId: string | OrderCopy, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Order>;
41
- order_subscription(orderCopyId: string | OrderCopy, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<OrderSubscription>;
42
43
  events(orderCopyId: string | OrderCopy, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Event>>;
44
+ order_subscription(orderCopyId: string | OrderCopy, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<OrderSubscription>;
43
45
  isOrderCopy(resource: any): resource is OrderCopy;
44
46
  relationship(id: string | ResourceId | null): OrderCopyRel;
45
47
  type(): OrderCopyType;
46
48
  }
47
49
  export default OrderCopies;
48
- export type { OrderCopy, OrderCopyCreate, OrderCopyType };
50
+ export type { OrderCopy, OrderCopyCreate, OrderCopyUpdate, OrderCopyType };
@@ -3,6 +3,9 @@ class OrderCopies extends ApiResource {
3
3
  async create(resource, params, options) {
4
4
  return this.resources.create({ ...resource, type: OrderCopies.TYPE }, params, options);
5
5
  }
6
+ async update(resource, params, options) {
7
+ return this.resources.update({ ...resource, type: OrderCopies.TYPE }, params, options);
8
+ }
6
9
  async delete(id, options) {
7
10
  await this.resources.delete((typeof id === 'string') ? { id, type: OrderCopies.TYPE } : id, options);
8
11
  }
@@ -14,14 +17,14 @@ class OrderCopies extends ApiResource {
14
17
  const _orderCopyId = orderCopyId.id || orderCopyId;
15
18
  return this.resources.fetch({ type: 'orders' }, `order_copies/${_orderCopyId}/target_order`, params, options);
16
19
  }
17
- async order_subscription(orderCopyId, params, options) {
18
- const _orderCopyId = orderCopyId.id || orderCopyId;
19
- return this.resources.fetch({ type: 'order_subscriptions' }, `order_copies/${_orderCopyId}/order_subscription`, params, options);
20
- }
21
20
  async events(orderCopyId, params, options) {
22
21
  const _orderCopyId = orderCopyId.id || orderCopyId;
23
22
  return this.resources.fetch({ type: 'events' }, `order_copies/${_orderCopyId}/events`, params, options);
24
23
  }
24
+ async order_subscription(orderCopyId, params, options) {
25
+ const _orderCopyId = orderCopyId.id || orderCopyId;
26
+ return this.resources.fetch({ type: 'order_subscriptions' }, `order_copies/${_orderCopyId}/order_subscription`, params, options);
27
+ }
25
28
  isOrderCopy(resource) {
26
29
  return resource.type && (resource.type === OrderCopies.TYPE);
27
30
  }
@@ -0,0 +1,33 @@
1
+ import { ApiResource, Resource, ResourceId, ResourcesConfig, ResourceRel, ListResponse } from '../resource';
2
+ import type { QueryParamsRetrieve, QueryParamsList } from '../query';
3
+ import type { Order } from './orders';
4
+ import type { Event } from './events';
5
+ type OrderFactoryType = 'order_factories';
6
+ type OrderFactoryRel = ResourceRel & {
7
+ type: OrderFactoryType;
8
+ };
9
+ interface OrderFactory extends Resource {
10
+ readonly type: OrderFactoryType;
11
+ status?: string | null;
12
+ started_at?: string | null;
13
+ completed_at?: string | null;
14
+ failed_at?: string | null;
15
+ errors_log?: object | null;
16
+ errors_count?: number | null;
17
+ place_target_order?: boolean | null;
18
+ reuse_wallet?: boolean | null;
19
+ source_order?: Order | null;
20
+ target_order?: Order | null;
21
+ events?: Event[] | null;
22
+ }
23
+ declare class OrderFactories extends ApiResource<OrderFactory> {
24
+ static readonly TYPE: OrderFactoryType;
25
+ source_order(orderFactoryId: string | OrderFactory, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Order>;
26
+ target_order(orderFactoryId: string | OrderFactory, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Order>;
27
+ events(orderFactoryId: string | OrderFactory, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Event>>;
28
+ isOrderFactory(resource: any): resource is OrderFactory;
29
+ relationship(id: string | ResourceId | null): OrderFactoryRel;
30
+ type(): OrderFactoryType;
31
+ }
32
+ export default OrderFactories;
33
+ export type { OrderFactory, OrderFactoryType };
@@ -0,0 +1,26 @@
1
+ import { ApiResource } from '../resource';
2
+ class OrderFactories extends ApiResource {
3
+ async source_order(orderFactoryId, params, options) {
4
+ const _orderFactoryId = orderFactoryId.id || orderFactoryId;
5
+ return this.resources.fetch({ type: 'orders' }, `order_factories/${_orderFactoryId}/source_order`, params, options);
6
+ }
7
+ async target_order(orderFactoryId, params, options) {
8
+ const _orderFactoryId = orderFactoryId.id || orderFactoryId;
9
+ return this.resources.fetch({ type: 'orders' }, `order_factories/${_orderFactoryId}/target_order`, params, options);
10
+ }
11
+ async events(orderFactoryId, params, options) {
12
+ const _orderFactoryId = orderFactoryId.id || orderFactoryId;
13
+ return this.resources.fetch({ type: 'events' }, `order_factories/${_orderFactoryId}/events`, params, options);
14
+ }
15
+ isOrderFactory(resource) {
16
+ return resource.type && (resource.type === OrderFactories.TYPE);
17
+ }
18
+ relationship(id) {
19
+ return ((id === null) || (typeof id === 'string')) ? { id, type: OrderFactories.TYPE } : { id: id.id, type: OrderFactories.TYPE };
20
+ }
21
+ type() {
22
+ return OrderFactories.TYPE;
23
+ }
24
+ }
25
+ OrderFactories.TYPE = 'order_factories';
26
+ export default OrderFactories;
@@ -0,0 +1,60 @@
1
+ import { ApiResource, Resource, ResourceCreate, ResourceUpdate, ResourceId, ResourcesConfig, ResourceRel } from '../resource';
2
+ import type { QueryParamsRetrieve } from '../query';
3
+ import type { OrderSubscription, OrderSubscriptionType } from './order_subscriptions';
4
+ import type { Adjustment, AdjustmentType } from './adjustments';
5
+ import type { Bundle, BundleType } from './bundles';
6
+ import type { Sku, SkuType } from './skus';
7
+ type OrderSubscriptionItemType = 'order_subscription_items';
8
+ type OrderSubscriptionItemRel = ResourceRel & {
9
+ type: OrderSubscriptionItemType;
10
+ };
11
+ type OrderSubscriptionRel = ResourceRel & {
12
+ type: OrderSubscriptionType;
13
+ };
14
+ type AdjustmentRel = ResourceRel & {
15
+ type: AdjustmentType;
16
+ };
17
+ type BundleRel = ResourceRel & {
18
+ type: BundleType;
19
+ };
20
+ type SkuRel = ResourceRel & {
21
+ type: SkuType;
22
+ };
23
+ interface OrderSubscriptionItem extends Resource {
24
+ readonly type: OrderSubscriptionItemType;
25
+ quantity: number;
26
+ unit_amount_cents?: number | null;
27
+ unit_amount_float?: number | null;
28
+ formatted_unit_amount?: string | null;
29
+ total_amount_cents?: number | null;
30
+ total_amount_float: number;
31
+ formatted_total_amount?: string | null;
32
+ order_subscription?: OrderSubscription | null;
33
+ item?: Adjustment | Bundle | Sku | null;
34
+ }
35
+ interface OrderSubscriptionItemCreate extends ResourceCreate {
36
+ sku_code?: string | null;
37
+ bundle_code?: string | null;
38
+ quantity: number;
39
+ unit_amount_cents?: number | null;
40
+ order_subscription: OrderSubscriptionRel;
41
+ item: AdjustmentRel | BundleRel | SkuRel;
42
+ }
43
+ interface OrderSubscriptionItemUpdate extends ResourceUpdate {
44
+ sku_code?: string | null;
45
+ bundle_code?: string | null;
46
+ quantity?: number | null;
47
+ unit_amount_cents?: number | null;
48
+ }
49
+ declare class OrderSubscriptionItems extends ApiResource<OrderSubscriptionItem> {
50
+ static readonly TYPE: OrderSubscriptionItemType;
51
+ create(resource: OrderSubscriptionItemCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<OrderSubscriptionItem>;
52
+ update(resource: OrderSubscriptionItemUpdate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<OrderSubscriptionItem>;
53
+ delete(id: string | ResourceId, options?: ResourcesConfig): Promise<void>;
54
+ order_subscription(orderSubscriptionItemId: string | OrderSubscriptionItem, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<OrderSubscription>;
55
+ isOrderSubscriptionItem(resource: any): resource is OrderSubscriptionItem;
56
+ relationship(id: string | ResourceId | null): OrderSubscriptionItemRel;
57
+ type(): OrderSubscriptionItemType;
58
+ }
59
+ export default OrderSubscriptionItems;
60
+ export type { OrderSubscriptionItem, OrderSubscriptionItemCreate, OrderSubscriptionItemUpdate, OrderSubscriptionItemType };
@@ -0,0 +1,27 @@
1
+ import { ApiResource } from '../resource';
2
+ class OrderSubscriptionItems extends ApiResource {
3
+ async create(resource, params, options) {
4
+ return this.resources.create({ ...resource, type: OrderSubscriptionItems.TYPE }, params, options);
5
+ }
6
+ async update(resource, params, options) {
7
+ return this.resources.update({ ...resource, type: OrderSubscriptionItems.TYPE }, params, options);
8
+ }
9
+ async delete(id, options) {
10
+ await this.resources.delete((typeof id === 'string') ? { id, type: OrderSubscriptionItems.TYPE } : id, options);
11
+ }
12
+ async order_subscription(orderSubscriptionItemId, params, options) {
13
+ const _orderSubscriptionItemId = orderSubscriptionItemId.id || orderSubscriptionItemId;
14
+ return this.resources.fetch({ type: 'order_subscriptions' }, `order_subscription_items/${_orderSubscriptionItemId}/order_subscription`, params, options);
15
+ }
16
+ isOrderSubscriptionItem(resource) {
17
+ return resource.type && (resource.type === OrderSubscriptionItems.TYPE);
18
+ }
19
+ relationship(id) {
20
+ return ((id === null) || (typeof id === 'string')) ? { id, type: OrderSubscriptionItems.TYPE } : { id: id.id, type: OrderSubscriptionItems.TYPE };
21
+ }
22
+ type() {
23
+ return OrderSubscriptionItems.TYPE;
24
+ }
25
+ }
26
+ OrderSubscriptionItems.TYPE = 'order_subscription_items';
27
+ export default OrderSubscriptionItems;
@@ -1,9 +1,13 @@
1
1
  import { ApiResource, Resource, ResourceCreate, ResourceUpdate, ResourceId, ResourcesConfig, ResourceRel, ListResponse } from '../resource';
2
2
  import type { QueryParamsRetrieve, QueryParamsList } from '../query';
3
3
  import type { Market, MarketType } from './markets';
4
+ import type { SubscriptionModel } from './subscription_models';
4
5
  import type { Order, OrderType } from './orders';
5
6
  import type { Customer } from './customers';
6
- import type { OrderCopy } from './order_copies';
7
+ import type { CustomerPaymentSource, CustomerPaymentSourceType } from './customer_payment_sources';
8
+ import type { OrderSubscriptionItem } from './order_subscription_items';
9
+ import type { OrderFactory } from './order_factories';
10
+ import type { RecurringOrderCopy } from './recurring_order_copies';
7
11
  import type { Event } from './events';
8
12
  type OrderSubscriptionType = 'order_subscriptions';
9
13
  type OrderSubscriptionRel = ResourceRel & {
@@ -15,6 +19,9 @@ type MarketRel = ResourceRel & {
15
19
  type OrderRel = ResourceRel & {
16
20
  type: OrderType;
17
21
  };
22
+ type CustomerPaymentSourceRel = ResourceRel & {
23
+ type: CustomerPaymentSourceType;
24
+ };
18
25
  interface OrderSubscription extends Resource {
19
26
  readonly type: OrderSubscriptionType;
20
27
  number?: string | null;
@@ -30,9 +37,17 @@ interface OrderSubscription extends Resource {
30
37
  succeeded_on_last_run?: boolean | null;
31
38
  options?: object | null;
32
39
  market?: Market | null;
40
+ subscription_model?: SubscriptionModel | null;
33
41
  source_order?: Order | null;
34
42
  customer?: Customer | null;
35
- order_copies?: OrderCopy[] | null;
43
+ customer_payment_source?: CustomerPaymentSource | null;
44
+ order_subscription_items?: OrderSubscriptionItem[] | null;
45
+ order_factories?: OrderFactory[] | null;
46
+ /**
47
+ * @deprecated This field should not be used as it may be removed in the future without notice
48
+ */
49
+ order_copies?: object[];
50
+ recurring_order_copies?: RecurringOrderCopy[] | null;
36
51
  orders?: Order[] | null;
37
52
  events?: Event[] | null;
38
53
  }
@@ -46,10 +61,13 @@ interface OrderSubscriptionCreate extends ResourceCreate {
46
61
  source_order: OrderRel;
47
62
  }
48
63
  interface OrderSubscriptionUpdate extends ResourceUpdate {
64
+ frequency?: string | null;
49
65
  expires_at?: string | null;
66
+ next_run_at?: string | null;
50
67
  _activate?: boolean | null;
51
68
  _deactivate?: boolean | null;
52
69
  _cancel?: boolean | null;
70
+ customer_payment_source?: CustomerPaymentSourceRel | null;
53
71
  }
54
72
  declare class OrderSubscriptions extends ApiResource<OrderSubscription> {
55
73
  static readonly TYPE: OrderSubscriptionType;
@@ -57,9 +75,13 @@ declare class OrderSubscriptions extends ApiResource<OrderSubscription> {
57
75
  update(resource: OrderSubscriptionUpdate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<OrderSubscription>;
58
76
  delete(id: string | ResourceId, options?: ResourcesConfig): Promise<void>;
59
77
  market(orderSubscriptionId: string | OrderSubscription, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Market>;
78
+ subscription_model(orderSubscriptionId: string | OrderSubscription, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<SubscriptionModel>;
60
79
  source_order(orderSubscriptionId: string | OrderSubscription, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Order>;
61
80
  customer(orderSubscriptionId: string | OrderSubscription, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Customer>;
62
- order_copies(orderSubscriptionId: string | OrderSubscription, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<OrderCopy>>;
81
+ customer_payment_source(orderSubscriptionId: string | OrderSubscription, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<CustomerPaymentSource>;
82
+ order_subscription_items(orderSubscriptionId: string | OrderSubscription, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<OrderSubscriptionItem>>;
83
+ order_factories(orderSubscriptionId: string | OrderSubscription, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<OrderFactory>>;
84
+ recurring_order_copies(orderSubscriptionId: string | OrderSubscription, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<RecurringOrderCopy>>;
63
85
  orders(orderSubscriptionId: string | OrderSubscription, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Order>>;
64
86
  events(orderSubscriptionId: string | OrderSubscription, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Event>>;
65
87
  isOrderSubscription(resource: any): resource is OrderSubscription;
@@ -13,6 +13,10 @@ class OrderSubscriptions extends ApiResource {
13
13
  const _orderSubscriptionId = orderSubscriptionId.id || orderSubscriptionId;
14
14
  return this.resources.fetch({ type: 'markets' }, `order_subscriptions/${_orderSubscriptionId}/market`, params, options);
15
15
  }
16
+ async subscription_model(orderSubscriptionId, params, options) {
17
+ const _orderSubscriptionId = orderSubscriptionId.id || orderSubscriptionId;
18
+ return this.resources.fetch({ type: 'subscription_models' }, `order_subscriptions/${_orderSubscriptionId}/subscription_model`, params, options);
19
+ }
16
20
  async source_order(orderSubscriptionId, params, options) {
17
21
  const _orderSubscriptionId = orderSubscriptionId.id || orderSubscriptionId;
18
22
  return this.resources.fetch({ type: 'orders' }, `order_subscriptions/${_orderSubscriptionId}/source_order`, params, options);
@@ -21,9 +25,21 @@ class OrderSubscriptions extends ApiResource {
21
25
  const _orderSubscriptionId = orderSubscriptionId.id || orderSubscriptionId;
22
26
  return this.resources.fetch({ type: 'customers' }, `order_subscriptions/${_orderSubscriptionId}/customer`, params, options);
23
27
  }
24
- async order_copies(orderSubscriptionId, params, options) {
28
+ async customer_payment_source(orderSubscriptionId, params, options) {
29
+ const _orderSubscriptionId = orderSubscriptionId.id || orderSubscriptionId;
30
+ return this.resources.fetch({ type: 'customer_payment_sources' }, `order_subscriptions/${_orderSubscriptionId}/customer_payment_source`, params, options);
31
+ }
32
+ async order_subscription_items(orderSubscriptionId, params, options) {
33
+ const _orderSubscriptionId = orderSubscriptionId.id || orderSubscriptionId;
34
+ return this.resources.fetch({ type: 'order_subscription_items' }, `order_subscriptions/${_orderSubscriptionId}/order_subscription_items`, params, options);
35
+ }
36
+ async order_factories(orderSubscriptionId, params, options) {
37
+ const _orderSubscriptionId = orderSubscriptionId.id || orderSubscriptionId;
38
+ return this.resources.fetch({ type: 'order_factories' }, `order_subscriptions/${_orderSubscriptionId}/order_factories`, params, options);
39
+ }
40
+ async recurring_order_copies(orderSubscriptionId, params, options) {
25
41
  const _orderSubscriptionId = orderSubscriptionId.id || orderSubscriptionId;
26
- return this.resources.fetch({ type: 'order_copies' }, `order_subscriptions/${_orderSubscriptionId}/order_copies`, params, options);
42
+ return this.resources.fetch({ type: 'recurring_order_copies' }, `order_subscriptions/${_orderSubscriptionId}/recurring_order_copies`, params, options);
27
43
  }
28
44
  async orders(orderSubscriptionId, params, options) {
29
45
  const _orderSubscriptionId = orderSubscriptionId.id || orderSubscriptionId;
@@ -25,7 +25,9 @@ import type { Capture } from './captures';
25
25
  import type { Refund } from './refunds';
26
26
  import type { Return } from './returns';
27
27
  import type { OrderSubscription } from './order_subscriptions';
28
+ import type { OrderFactory } from './order_factories';
28
29
  import type { OrderCopy } from './order_copies';
30
+ import type { RecurringOrderCopy } from './recurring_order_copies';
29
31
  import type { Attachment } from './attachments';
30
32
  import type { Event } from './events';
31
33
  type OrderType = 'orders';
@@ -79,7 +81,7 @@ interface Order extends Resource {
79
81
  number?: number | null;
80
82
  autorefresh?: boolean | null;
81
83
  status?: 'draft' | 'pending' | 'placed' | 'approved' | 'cancelled' | null;
82
- payment_status?: 'unpaid' | 'authorized' | 'paid' | 'voided' | 'refunded' | 'free' | null;
84
+ payment_status?: 'unpaid' | 'authorized' | 'partially_authorized' | 'paid' | 'partially_paid' | 'voided' | 'partially_voided' | 'refunded' | 'partially_refunded' | 'free' | null;
83
85
  fulfillment_status?: 'unfulfilled' | 'in_progress' | 'fulfilled' | 'not_required' | null;
84
86
  guest?: boolean | null;
85
87
  editable?: boolean | null;
@@ -174,6 +176,7 @@ interface Order extends Resource {
174
176
  refreshed_at?: string | null;
175
177
  archived_at?: string | null;
176
178
  expires_at?: string | null;
179
+ subscription_created_at?: string | null;
177
180
  market?: Market | null;
178
181
  customer?: Customer | null;
179
182
  shipping_address?: Address | null;
@@ -193,7 +196,9 @@ interface Order extends Resource {
193
196
  refunds?: Refund[] | null;
194
197
  returns?: Return[] | null;
195
198
  order_subscriptions?: OrderSubscription[] | null;
199
+ order_factories?: OrderFactory[] | null;
196
200
  order_copies?: OrderCopy[] | null;
201
+ recurring_order_copies?: RecurringOrderCopy[] | null;
197
202
  attachments?: Attachment[] | null;
198
203
  events?: Event[] | null;
199
204
  }
@@ -256,6 +261,7 @@ interface OrderUpdate extends ResourceUpdate {
256
261
  _save_billing_address_to_customer_address_book?: boolean | null;
257
262
  _refresh?: boolean | null;
258
263
  _validate?: boolean | null;
264
+ _create_subscriptions?: boolean | null;
259
265
  market?: MarketRel | null;
260
266
  customer?: CustomerRel | null;
261
267
  shipping_address?: AddressRel | null;
@@ -285,7 +291,9 @@ declare class Orders extends ApiResource<Order> {
285
291
  refunds(orderId: string | Order, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Refund>>;
286
292
  returns(orderId: string | Order, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Return>>;
287
293
  order_subscriptions(orderId: string | Order, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<OrderSubscription>>;
294
+ order_factories(orderId: string | Order, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<OrderFactory>>;
288
295
  order_copies(orderId: string | Order, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<OrderCopy>>;
296
+ recurring_order_copies(orderId: string | Order, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<RecurringOrderCopy>>;
289
297
  attachments(orderId: string | Order, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Attachment>>;
290
298
  events(orderId: string | Order, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Event>>;
291
299
  isOrder(resource: any): resource is Order;
@@ -77,10 +77,18 @@ class Orders extends ApiResource {
77
77
  const _orderId = orderId.id || orderId;
78
78
  return this.resources.fetch({ type: 'order_subscriptions' }, `orders/${_orderId}/order_subscriptions`, params, options);
79
79
  }
80
+ async order_factories(orderId, params, options) {
81
+ const _orderId = orderId.id || orderId;
82
+ return this.resources.fetch({ type: 'order_factories' }, `orders/${_orderId}/order_factories`, params, options);
83
+ }
80
84
  async order_copies(orderId, params, options) {
81
85
  const _orderId = orderId.id || orderId;
82
86
  return this.resources.fetch({ type: 'order_copies' }, `orders/${_orderId}/order_copies`, params, options);
83
87
  }
88
+ async recurring_order_copies(orderId, params, options) {
89
+ const _orderId = orderId.id || orderId;
90
+ return this.resources.fetch({ type: 'recurring_order_copies' }, `orders/${_orderId}/recurring_order_copies`, params, options);
91
+ }
84
92
  async attachments(orderId, params, options) {
85
93
  const _orderId = orderId.id || orderId;
86
94
  return this.resources.fetch({ type: 'attachments' }, `orders/${_orderId}/attachments`, params, options);
@@ -6,9 +6,9 @@ import type { OrderAmountPromotionRule, OrderAmountPromotionRuleType } from './o
6
6
  import type { SkuListPromotionRule, SkuListPromotionRuleType } from './sku_list_promotion_rules';
7
7
  import type { CouponCodesPromotionRule, CouponCodesPromotionRuleType } from './coupon_codes_promotion_rules';
8
8
  import type { Attachment } from './attachments';
9
+ import type { Event } from './events';
9
10
  import type { SkuList, SkuListType } from './sku_lists';
10
11
  import type { Sku } from './skus';
11
- import type { Event } from './events';
12
12
  type PercentageDiscountPromotionType = 'percentage_discount_promotions';
13
13
  type PercentageDiscountPromotionRel = ResourceRel & {
14
14
  type: PercentageDiscountPromotionType;
@@ -47,9 +47,9 @@ interface PercentageDiscountPromotion extends Resource {
47
47
  sku_list_promotion_rule?: SkuListPromotionRule | null;
48
48
  coupon_codes_promotion_rule?: CouponCodesPromotionRule | null;
49
49
  attachments?: Attachment[] | null;
50
+ events?: Event[] | null;
50
51
  sku_list?: SkuList | null;
51
52
  skus?: Sku[] | null;
52
- events?: Event[] | null;
53
53
  }
54
54
  interface PercentageDiscountPromotionCreate extends ResourceCreate {
55
55
  name: string;
@@ -89,9 +89,9 @@ declare class PercentageDiscountPromotions extends ApiResource<PercentageDiscoun
89
89
  sku_list_promotion_rule(percentageDiscountPromotionId: string | PercentageDiscountPromotion, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<SkuListPromotionRule>;
90
90
  coupon_codes_promotion_rule(percentageDiscountPromotionId: string | PercentageDiscountPromotion, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<CouponCodesPromotionRule>;
91
91
  attachments(percentageDiscountPromotionId: string | PercentageDiscountPromotion, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Attachment>>;
92
+ events(percentageDiscountPromotionId: string | PercentageDiscountPromotion, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Event>>;
92
93
  sku_list(percentageDiscountPromotionId: string | PercentageDiscountPromotion, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<SkuList>;
93
94
  skus(percentageDiscountPromotionId: string | PercentageDiscountPromotion, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Sku>>;
94
- events(percentageDiscountPromotionId: string | PercentageDiscountPromotion, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Event>>;
95
95
  isPercentageDiscountPromotion(resource: any): resource is PercentageDiscountPromotion;
96
96
  relationship(id: string | ResourceId | null): PercentageDiscountPromotionRel;
97
97
  type(): PercentageDiscountPromotionType;
@@ -29,6 +29,10 @@ class PercentageDiscountPromotions extends ApiResource {
29
29
  const _percentageDiscountPromotionId = percentageDiscountPromotionId.id || percentageDiscountPromotionId;
30
30
  return this.resources.fetch({ type: 'attachments' }, `percentage_discount_promotions/${_percentageDiscountPromotionId}/attachments`, params, options);
31
31
  }
32
+ async events(percentageDiscountPromotionId, params, options) {
33
+ const _percentageDiscountPromotionId = percentageDiscountPromotionId.id || percentageDiscountPromotionId;
34
+ return this.resources.fetch({ type: 'events' }, `percentage_discount_promotions/${_percentageDiscountPromotionId}/events`, params, options);
35
+ }
32
36
  async sku_list(percentageDiscountPromotionId, params, options) {
33
37
  const _percentageDiscountPromotionId = percentageDiscountPromotionId.id || percentageDiscountPromotionId;
34
38
  return this.resources.fetch({ type: 'sku_lists' }, `percentage_discount_promotions/${_percentageDiscountPromotionId}/sku_list`, params, options);
@@ -37,10 +41,6 @@ class PercentageDiscountPromotions extends ApiResource {
37
41
  const _percentageDiscountPromotionId = percentageDiscountPromotionId.id || percentageDiscountPromotionId;
38
42
  return this.resources.fetch({ type: 'skus' }, `percentage_discount_promotions/${_percentageDiscountPromotionId}/skus`, params, options);
39
43
  }
40
- async events(percentageDiscountPromotionId, params, options) {
41
- const _percentageDiscountPromotionId = percentageDiscountPromotionId.id || percentageDiscountPromotionId;
42
- return this.resources.fetch({ type: 'events' }, `percentage_discount_promotions/${_percentageDiscountPromotionId}/events`, params, options);
43
- }
44
44
  isPercentageDiscountPromotion(resource) {
45
45
  return resource.type && (resource.type === PercentageDiscountPromotions.TYPE);
46
46
  }