@commercelayer/sdk 4.26.0 → 4.27.1

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 (83) hide show
  1. package/lib/cjs/api.d.ts +7 -2
  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/micro.d.ts +4 -0
  6. package/lib/cjs/micro.js +13 -0
  7. package/lib/cjs/model.d.ts +6 -1
  8. package/lib/cjs/resources/fixed_price_promotions.d.ts +3 -3
  9. package/lib/cjs/resources/fixed_price_promotions.js +4 -4
  10. package/lib/cjs/resources/free_gift_promotions.d.ts +3 -3
  11. package/lib/cjs/resources/free_gift_promotions.js +4 -4
  12. package/lib/cjs/resources/free_shipping_promotions.d.ts +3 -0
  13. package/lib/cjs/resources/free_shipping_promotions.js +4 -0
  14. package/lib/cjs/resources/line_items.d.ts +3 -0
  15. package/lib/cjs/resources/markets.d.ts +8 -0
  16. package/lib/cjs/resources/markets.js +4 -0
  17. package/lib/cjs/resources/order_copies.d.ts +11 -9
  18. package/lib/cjs/resources/order_copies.js +7 -4
  19. package/lib/cjs/resources/order_factories.d.ts +33 -0
  20. package/lib/cjs/resources/order_factories.js +36 -0
  21. package/lib/cjs/resources/order_subscription_items.d.ts +60 -0
  22. package/lib/cjs/resources/order_subscription_items.js +37 -0
  23. package/lib/cjs/resources/order_subscriptions.d.ts +25 -3
  24. package/lib/cjs/resources/order_subscriptions.js +18 -2
  25. package/lib/cjs/resources/orders.d.ts +8 -0
  26. package/lib/cjs/resources/orders.js +8 -0
  27. package/lib/cjs/resources/percentage_discount_promotions.d.ts +3 -3
  28. package/lib/cjs/resources/percentage_discount_promotions.js +4 -4
  29. package/lib/cjs/resources/price_frequency_tiers.d.ts +49 -0
  30. package/lib/cjs/resources/price_frequency_tiers.js +45 -0
  31. package/lib/cjs/resources/price_volume_tiers.d.ts +3 -0
  32. package/lib/cjs/resources/price_volume_tiers.js +4 -0
  33. package/lib/cjs/resources/prices.d.ts +3 -0
  34. package/lib/cjs/resources/prices.js +4 -0
  35. package/lib/cjs/resources/promotions.d.ts +3 -0
  36. package/lib/cjs/resources/promotions.js +4 -0
  37. package/lib/cjs/resources/recurring_order_copies.d.ts +52 -0
  38. package/lib/cjs/resources/recurring_order_copies.js +49 -0
  39. package/lib/cjs/resources/subscription_models.d.ts +48 -0
  40. package/lib/cjs/resources/subscription_models.js +45 -0
  41. package/lib/esm/api.d.ts +7 -2
  42. package/lib/esm/api.js +10 -0
  43. package/lib/esm/commercelayer.d.ts +7 -2
  44. package/lib/esm/commercelayer.js +6 -1
  45. package/lib/esm/micro.d.ts +4 -0
  46. package/lib/esm/micro.js +7 -0
  47. package/lib/esm/model.d.ts +6 -1
  48. package/lib/esm/resources/fixed_price_promotions.d.ts +3 -3
  49. package/lib/esm/resources/fixed_price_promotions.js +4 -4
  50. package/lib/esm/resources/free_gift_promotions.d.ts +3 -3
  51. package/lib/esm/resources/free_gift_promotions.js +4 -4
  52. package/lib/esm/resources/free_shipping_promotions.d.ts +3 -0
  53. package/lib/esm/resources/free_shipping_promotions.js +4 -0
  54. package/lib/esm/resources/line_items.d.ts +3 -0
  55. package/lib/esm/resources/markets.d.ts +8 -0
  56. package/lib/esm/resources/markets.js +4 -0
  57. package/lib/esm/resources/order_copies.d.ts +11 -9
  58. package/lib/esm/resources/order_copies.js +7 -4
  59. package/lib/esm/resources/order_factories.d.ts +33 -0
  60. package/lib/esm/resources/order_factories.js +34 -0
  61. package/lib/esm/resources/order_subscription_items.d.ts +60 -0
  62. package/lib/esm/resources/order_subscription_items.js +35 -0
  63. package/lib/esm/resources/order_subscriptions.d.ts +25 -3
  64. package/lib/esm/resources/order_subscriptions.js +18 -2
  65. package/lib/esm/resources/orders.d.ts +8 -0
  66. package/lib/esm/resources/orders.js +8 -0
  67. package/lib/esm/resources/percentage_discount_promotions.d.ts +3 -3
  68. package/lib/esm/resources/percentage_discount_promotions.js +4 -4
  69. package/lib/esm/resources/price_frequency_tiers.d.ts +49 -0
  70. package/lib/esm/resources/price_frequency_tiers.js +43 -0
  71. package/lib/esm/resources/price_volume_tiers.d.ts +3 -0
  72. package/lib/esm/resources/price_volume_tiers.js +4 -0
  73. package/lib/esm/resources/prices.d.ts +3 -0
  74. package/lib/esm/resources/prices.js +4 -0
  75. package/lib/esm/resources/promotions.d.ts +3 -0
  76. package/lib/esm/resources/promotions.js +4 -0
  77. package/lib/esm/resources/recurring_order_copies.d.ts +52 -0
  78. package/lib/esm/resources/recurring_order_copies.js +47 -0
  79. package/lib/esm/resources/subscription_models.d.ts +48 -0
  80. package/lib/esm/resources/subscription_models.js +43 -0
  81. package/lib/tsconfig.esm.tsbuildinfo +1 -1
  82. package/lib/tsconfig.tsbuildinfo +1 -1
  83. package/package.json +21 -21
@@ -76,6 +76,7 @@ interface LineItem extends Resource {
76
76
  tax_rate?: number;
77
77
  tax_breakdown?: object;
78
78
  item_type?: string;
79
+ frequency?: string;
79
80
  order?: Order;
80
81
  item?: Adjustment | Bundle | ExternalPromotion | FixedAmountPromotion | FreeShippingPromotion | GiftCard | PaymentMethod | PercentageDiscountPromotion | Shipment | Sku;
81
82
  line_item_options?: LineItemOption[];
@@ -96,6 +97,7 @@ interface LineItemCreate extends ResourceCreate {
96
97
  name?: string;
97
98
  image_url?: string;
98
99
  item_type?: string;
100
+ frequency?: string;
99
101
  order: OrderRel;
100
102
  item?: AdjustmentRel | BundleRel | ExternalPromotionRel | FixedAmountPromotionRel | FreeShippingPromotionRel | GiftCardRel | PaymentMethodRel | PercentageDiscountPromotionRel | ShipmentRel | SkuRel;
101
103
  }
@@ -106,6 +108,7 @@ interface LineItemUpdate extends ResourceUpdate {
106
108
  _external_price?: boolean;
107
109
  name?: string;
108
110
  image_url?: string;
111
+ frequency?: string;
109
112
  }
110
113
  declare class LineItems extends ApiResource {
111
114
  static readonly TYPE: 'line_items';
@@ -3,6 +3,7 @@ import type { QueryParamsList, QueryParamsRetrieve } from '../query';
3
3
  import type { Merchant } from './merchants';
4
4
  import type { PriceList } from './price_lists';
5
5
  import type { InventoryModel } from './inventory_models';
6
+ import type { SubscriptionModel } from './subscription_models';
6
7
  import type { TaxCalculator } from './tax_calculators';
7
8
  import type { CustomerGroup } from './customer_groups';
8
9
  import type { Attachment } from './attachments';
@@ -18,6 +19,9 @@ type PriceListRel = ResourceRel & {
18
19
  type InventoryModelRel = ResourceRel & {
19
20
  type: 'inventory_models';
20
21
  };
22
+ type SubscriptionModelRel = ResourceRel & {
23
+ type: 'subscription_models';
24
+ };
21
25
  type TaxCalculatorRel = ResourceRel & {
22
26
  type: 'tax_calculators';
23
27
  };
@@ -37,6 +41,7 @@ interface Market extends Resource {
37
41
  merchant?: Merchant;
38
42
  price_list?: PriceList;
39
43
  inventory_model?: InventoryModel;
44
+ subscription_model?: SubscriptionModel;
40
45
  tax_calculator?: TaxCalculator;
41
46
  customer_group?: CustomerGroup;
42
47
  attachments?: Attachment[];
@@ -50,6 +55,7 @@ interface MarketCreate extends ResourceCreate {
50
55
  merchant: MerchantRel;
51
56
  price_list: PriceListRel;
52
57
  inventory_model: InventoryModelRel;
58
+ subscription_model?: SubscriptionModelRel;
53
59
  tax_calculator?: TaxCalculatorRel;
54
60
  customer_group?: CustomerGroupRel;
55
61
  }
@@ -64,6 +70,7 @@ interface MarketUpdate extends ResourceUpdate {
64
70
  merchant?: MerchantRel;
65
71
  price_list?: PriceListRel;
66
72
  inventory_model?: InventoryModelRel;
73
+ subscription_model?: SubscriptionModelRel;
67
74
  tax_calculator?: TaxCalculatorRel;
68
75
  customer_group?: CustomerGroupRel;
69
76
  }
@@ -77,6 +84,7 @@ declare class Markets extends ApiResource {
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>>;
@@ -28,6 +28,10 @@ class Markets extends ApiResource {
28
28
  const _marketId = marketId.id || marketId;
29
29
  return this.resources.fetch({ type: 'inventory_models' }, `markets/${_marketId}/inventory_model`, params, options);
30
30
  }
31
+ async subscription_model(marketId, params, options) {
32
+ const _marketId = marketId.id || marketId;
33
+ return this.resources.fetch({ type: 'subscription_models' }, `markets/${_marketId}/subscription_model`, params, options);
34
+ }
31
35
  async tax_calculator(marketId, params, options) {
32
36
  const _marketId = marketId.id || marketId;
33
37
  return this.resources.fetch({ type: 'tax_calculators' }, `markets/${_marketId}/tax_calculator`, params, options);
@@ -1,8 +1,8 @@
1
- import { ApiResource, Resource, ResourceCreate, ResourcesConfig, ResourceId, ResourceRel, ListResponse } from '../resource';
1
+ import { ApiResource, Resource, ResourceCreate, ResourceUpdate, ResourcesConfig, ResourceId, ResourceRel, ListResponse } from '../resource';
2
2
  import type { QueryParamsList, QueryParamsRetrieve } from '../query';
3
3
  import type { Order } 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 OrderCopyRel = ResourceRel & {
7
7
  type: typeof OrderCopies.TYPE;
8
8
  };
@@ -14,35 +14,37 @@ interface OrderCopy extends Resource {
14
14
  started_at?: string;
15
15
  completed_at?: string;
16
16
  failed_at?: string;
17
- place_target_order?: boolean;
18
- cancel_source_order?: boolean;
19
- reuse_wallet?: boolean;
20
17
  errors_log?: object;
21
18
  errors_count?: number;
19
+ place_target_order?: boolean;
20
+ reuse_wallet?: boolean;
21
+ cancel_source_order?: boolean;
22
22
  source_order?: Order;
23
23
  target_order?: Order;
24
- order_subscription?: OrderSubscription;
25
24
  events?: Event[];
25
+ order_subscription?: OrderSubscription;
26
26
  }
27
27
  interface OrderCopyCreate extends ResourceCreate {
28
28
  place_target_order?: boolean;
29
- cancel_source_order?: boolean;
30
29
  reuse_wallet?: boolean;
30
+ cancel_source_order?: boolean;
31
31
  source_order: OrderRel;
32
32
  }
33
+ type OrderCopyUpdate = ResourceUpdate;
33
34
  declare class OrderCopies extends ApiResource {
34
35
  static readonly TYPE: 'order_copies';
35
36
  list(params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<OrderCopy>>;
36
37
  create(resource: OrderCopyCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<OrderCopy>;
37
38
  retrieve(id: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<OrderCopy>;
39
+ update(resource: OrderCopyUpdate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<OrderCopy>;
38
40
  delete(id: string, 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(): string;
46
48
  }
47
49
  export default OrderCopies;
48
- export { OrderCopy, OrderCopyCreate };
50
+ export { OrderCopy, OrderCopyCreate, OrderCopyUpdate };
@@ -10,6 +10,9 @@ class OrderCopies extends ApiResource {
10
10
  async retrieve(id, params, options) {
11
11
  return this.resources.retrieve({ type: OrderCopies.TYPE, id }, params, options);
12
12
  }
13
+ async update(resource, params, options) {
14
+ return this.resources.update(Object.assign(Object.assign({}, resource), { type: OrderCopies.TYPE }), params, options);
15
+ }
13
16
  async delete(id, options) {
14
17
  await this.resources.delete({ type: OrderCopies.TYPE, id }, options);
15
18
  }
@@ -21,14 +24,14 @@ class OrderCopies extends ApiResource {
21
24
  const _orderCopyId = orderCopyId.id || orderCopyId;
22
25
  return this.resources.fetch({ type: 'orders' }, `order_copies/${_orderCopyId}/target_order`, params, options);
23
26
  }
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
- }
28
27
  async events(orderCopyId, params, options) {
29
28
  const _orderCopyId = orderCopyId.id || orderCopyId;
30
29
  return this.resources.fetch({ type: 'events' }, `order_copies/${_orderCopyId}/events`, params, options);
31
30
  }
31
+ async order_subscription(orderCopyId, params, options) {
32
+ const _orderCopyId = orderCopyId.id || orderCopyId;
33
+ return this.resources.fetch({ type: 'order_subscriptions' }, `order_copies/${_orderCopyId}/order_subscription`, params, options);
34
+ }
32
35
  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
33
36
  isOrderCopy(resource) {
34
37
  return resource.type && (resource.type === OrderCopies.TYPE);
@@ -0,0 +1,33 @@
1
+ import { ApiResource, Resource, ResourcesConfig, ResourceId, ResourceRel, ListResponse } from '../resource';
2
+ import type { QueryParamsList, QueryParamsRetrieve } from '../query';
3
+ import type { Order } from './orders';
4
+ import type { Event } from './events';
5
+ type OrderFactoryRel = ResourceRel & {
6
+ type: typeof OrderFactories.TYPE;
7
+ };
8
+ interface OrderFactory extends Resource {
9
+ status?: string;
10
+ started_at?: string;
11
+ completed_at?: string;
12
+ failed_at?: string;
13
+ errors_log?: object;
14
+ errors_count?: number;
15
+ place_target_order?: boolean;
16
+ reuse_wallet?: boolean;
17
+ source_order?: Order;
18
+ target_order?: Order;
19
+ events?: Event[];
20
+ }
21
+ declare class OrderFactories extends ApiResource {
22
+ static readonly TYPE: 'order_factories';
23
+ list(params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<OrderFactory>>;
24
+ retrieve(id: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<OrderFactory>;
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(): string;
31
+ }
32
+ export default OrderFactories;
33
+ export { OrderFactory };
@@ -0,0 +1,34 @@
1
+ import { ApiResource } from '../resource';
2
+ class OrderFactories extends ApiResource {
3
+ // static readonly PATH = 'order_factories'
4
+ async list(params, options) {
5
+ return this.resources.list({ type: OrderFactories.TYPE }, params, options);
6
+ }
7
+ async retrieve(id, params, options) {
8
+ return this.resources.retrieve({ type: OrderFactories.TYPE, id }, params, options);
9
+ }
10
+ async source_order(orderFactoryId, params, options) {
11
+ const _orderFactoryId = orderFactoryId.id || orderFactoryId;
12
+ return this.resources.fetch({ type: 'orders' }, `order_factories/${_orderFactoryId}/source_order`, params, options);
13
+ }
14
+ async target_order(orderFactoryId, params, options) {
15
+ const _orderFactoryId = orderFactoryId.id || orderFactoryId;
16
+ return this.resources.fetch({ type: 'orders' }, `order_factories/${_orderFactoryId}/target_order`, params, options);
17
+ }
18
+ async events(orderFactoryId, params, options) {
19
+ const _orderFactoryId = orderFactoryId.id || orderFactoryId;
20
+ return this.resources.fetch({ type: 'events' }, `order_factories/${_orderFactoryId}/events`, params, options);
21
+ }
22
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
23
+ isOrderFactory(resource) {
24
+ return resource.type && (resource.type === OrderFactories.TYPE);
25
+ }
26
+ relationship(id) {
27
+ return ((id === null) || (typeof id === 'string')) ? { id, type: OrderFactories.TYPE } : { id: id.id, type: OrderFactories.TYPE };
28
+ }
29
+ type() {
30
+ return OrderFactories.TYPE;
31
+ }
32
+ }
33
+ OrderFactories.TYPE = 'order_factories';
34
+ export default OrderFactories;
@@ -0,0 +1,60 @@
1
+ import { ApiResource, Resource, ResourceCreate, ResourceUpdate, ResourcesConfig, ResourceId, ResourceRel, ListResponse } from '../resource';
2
+ import type { QueryParamsList, QueryParamsRetrieve } from '../query';
3
+ import type { OrderSubscription } from './order_subscriptions';
4
+ import type { Adjustment } from './adjustments';
5
+ import type { Bundle } from './bundles';
6
+ import type { Sku } from './skus';
7
+ type OrderSubscriptionItemRel = ResourceRel & {
8
+ type: typeof OrderSubscriptionItems.TYPE;
9
+ };
10
+ type OrderSubscriptionRel = ResourceRel & {
11
+ type: 'order_subscriptions';
12
+ };
13
+ type AdjustmentRel = ResourceRel & {
14
+ type: 'adjustments';
15
+ };
16
+ type BundleRel = ResourceRel & {
17
+ type: 'bundles';
18
+ };
19
+ type SkuRel = ResourceRel & {
20
+ type: 'skus';
21
+ };
22
+ interface OrderSubscriptionItem extends Resource {
23
+ quantity?: number;
24
+ unit_amount_cents?: number;
25
+ unit_amount_float?: number;
26
+ formatted_unit_amount?: string;
27
+ total_amount_cents?: number;
28
+ total_amount_float?: number;
29
+ formatted_total_amount?: string;
30
+ order_subscription?: OrderSubscription;
31
+ item?: Adjustment | Bundle | Sku;
32
+ }
33
+ interface OrderSubscriptionItemCreate extends ResourceCreate {
34
+ sku_code?: string;
35
+ bundle_code?: string;
36
+ quantity: number;
37
+ unit_amount_cents?: number;
38
+ order_subscription: OrderSubscriptionRel;
39
+ item: AdjustmentRel | BundleRel | SkuRel;
40
+ }
41
+ interface OrderSubscriptionItemUpdate extends ResourceUpdate {
42
+ sku_code?: string;
43
+ bundle_code?: string;
44
+ quantity?: number;
45
+ unit_amount_cents?: number;
46
+ }
47
+ declare class OrderSubscriptionItems extends ApiResource {
48
+ static readonly TYPE: 'order_subscription_items';
49
+ list(params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<OrderSubscriptionItem>>;
50
+ create(resource: OrderSubscriptionItemCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<OrderSubscriptionItem>;
51
+ retrieve(id: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<OrderSubscriptionItem>;
52
+ update(resource: OrderSubscriptionItemUpdate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<OrderSubscriptionItem>;
53
+ delete(id: string, 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(): string;
58
+ }
59
+ export default OrderSubscriptionItems;
60
+ export { OrderSubscriptionItem, OrderSubscriptionItemCreate, OrderSubscriptionItemUpdate };
@@ -0,0 +1,35 @@
1
+ import { ApiResource } from '../resource';
2
+ class OrderSubscriptionItems extends ApiResource {
3
+ // static readonly PATH = 'order_subscription_items'
4
+ async list(params, options) {
5
+ return this.resources.list({ type: OrderSubscriptionItems.TYPE }, params, options);
6
+ }
7
+ async create(resource, params, options) {
8
+ return this.resources.create(Object.assign(Object.assign({}, resource), { type: OrderSubscriptionItems.TYPE }), params, options);
9
+ }
10
+ async retrieve(id, params, options) {
11
+ return this.resources.retrieve({ type: OrderSubscriptionItems.TYPE, id }, params, options);
12
+ }
13
+ async update(resource, params, options) {
14
+ return this.resources.update(Object.assign(Object.assign({}, resource), { type: OrderSubscriptionItems.TYPE }), params, options);
15
+ }
16
+ async delete(id, options) {
17
+ await this.resources.delete({ type: OrderSubscriptionItems.TYPE, id }, options);
18
+ }
19
+ async order_subscription(orderSubscriptionItemId, params, options) {
20
+ const _orderSubscriptionItemId = orderSubscriptionItemId.id || orderSubscriptionItemId;
21
+ return this.resources.fetch({ type: 'order_subscriptions' }, `order_subscription_items/${_orderSubscriptionItemId}/order_subscription`, params, options);
22
+ }
23
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
24
+ isOrderSubscriptionItem(resource) {
25
+ return resource.type && (resource.type === OrderSubscriptionItems.TYPE);
26
+ }
27
+ relationship(id) {
28
+ return ((id === null) || (typeof id === 'string')) ? { id, type: OrderSubscriptionItems.TYPE } : { id: id.id, type: OrderSubscriptionItems.TYPE };
29
+ }
30
+ type() {
31
+ return OrderSubscriptionItems.TYPE;
32
+ }
33
+ }
34
+ OrderSubscriptionItems.TYPE = 'order_subscription_items';
35
+ export default OrderSubscriptionItems;
@@ -1,9 +1,13 @@
1
1
  import { ApiResource, Resource, ResourceCreate, ResourceUpdate, ResourcesConfig, ResourceId, ResourceRel, ListResponse } from '../resource';
2
2
  import type { QueryParamsList, QueryParamsRetrieve } from '../query';
3
3
  import type { Market } from './markets';
4
+ import type { SubscriptionModel } from './subscription_models';
4
5
  import type { Order } from './orders';
5
6
  import type { Customer } from './customers';
6
- import type { OrderCopy } from './order_copies';
7
+ import type { CustomerPaymentSource } 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 OrderSubscriptionRel = ResourceRel & {
9
13
  type: typeof OrderSubscriptions.TYPE;
@@ -14,6 +18,9 @@ type MarketRel = ResourceRel & {
14
18
  type OrderRel = ResourceRel & {
15
19
  type: 'orders';
16
20
  };
21
+ type CustomerPaymentSourceRel = ResourceRel & {
22
+ type: 'customer_payment_sources';
23
+ };
17
24
  interface OrderSubscription extends Resource {
18
25
  number?: string;
19
26
  status?: string;
@@ -28,9 +35,17 @@ interface OrderSubscription extends Resource {
28
35
  succeeded_on_last_run?: boolean;
29
36
  options?: object;
30
37
  market?: Market;
38
+ subscription_model?: SubscriptionModel;
31
39
  source_order?: Order;
32
40
  customer?: Customer;
33
- order_copies?: OrderCopy[];
41
+ customer_payment_source?: CustomerPaymentSource;
42
+ order_subscription_items?: OrderSubscriptionItem[];
43
+ order_factories?: OrderFactory[];
44
+ /**
45
+ * @deprecated This field should not be used as it may be removed in the future without notice
46
+ */
47
+ order_copies?: object[];
48
+ recurring_order_copies?: RecurringOrderCopy[];
34
49
  orders?: Order[];
35
50
  events?: Event[];
36
51
  }
@@ -44,10 +59,13 @@ interface OrderSubscriptionCreate extends ResourceCreate {
44
59
  source_order: OrderRel;
45
60
  }
46
61
  interface OrderSubscriptionUpdate extends ResourceUpdate {
62
+ frequency?: string;
47
63
  expires_at?: string;
64
+ next_run_at?: string;
48
65
  _activate?: boolean;
49
66
  _deactivate?: boolean;
50
67
  _cancel?: boolean;
68
+ customer_payment_source?: CustomerPaymentSourceRel;
51
69
  }
52
70
  declare class OrderSubscriptions extends ApiResource {
53
71
  static readonly TYPE: 'order_subscriptions';
@@ -57,9 +75,13 @@ declare class OrderSubscriptions extends ApiResource {
57
75
  update(resource: OrderSubscriptionUpdate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<OrderSubscription>;
58
76
  delete(id: string, 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;
@@ -20,6 +20,10 @@ class OrderSubscriptions extends ApiResource {
20
20
  const _orderSubscriptionId = orderSubscriptionId.id || orderSubscriptionId;
21
21
  return this.resources.fetch({ type: 'markets' }, `order_subscriptions/${_orderSubscriptionId}/market`, params, options);
22
22
  }
23
+ async subscription_model(orderSubscriptionId, params, options) {
24
+ const _orderSubscriptionId = orderSubscriptionId.id || orderSubscriptionId;
25
+ return this.resources.fetch({ type: 'subscription_models' }, `order_subscriptions/${_orderSubscriptionId}/subscription_model`, params, options);
26
+ }
23
27
  async source_order(orderSubscriptionId, params, options) {
24
28
  const _orderSubscriptionId = orderSubscriptionId.id || orderSubscriptionId;
25
29
  return this.resources.fetch({ type: 'orders' }, `order_subscriptions/${_orderSubscriptionId}/source_order`, params, options);
@@ -28,9 +32,21 @@ class OrderSubscriptions extends ApiResource {
28
32
  const _orderSubscriptionId = orderSubscriptionId.id || orderSubscriptionId;
29
33
  return this.resources.fetch({ type: 'customers' }, `order_subscriptions/${_orderSubscriptionId}/customer`, params, options);
30
34
  }
31
- async order_copies(orderSubscriptionId, params, options) {
35
+ async customer_payment_source(orderSubscriptionId, params, options) {
36
+ const _orderSubscriptionId = orderSubscriptionId.id || orderSubscriptionId;
37
+ return this.resources.fetch({ type: 'customer_payment_sources' }, `order_subscriptions/${_orderSubscriptionId}/customer_payment_source`, params, options);
38
+ }
39
+ async order_subscription_items(orderSubscriptionId, params, options) {
40
+ const _orderSubscriptionId = orderSubscriptionId.id || orderSubscriptionId;
41
+ return this.resources.fetch({ type: 'order_subscription_items' }, `order_subscriptions/${_orderSubscriptionId}/order_subscription_items`, params, options);
42
+ }
43
+ async order_factories(orderSubscriptionId, params, options) {
44
+ const _orderSubscriptionId = orderSubscriptionId.id || orderSubscriptionId;
45
+ return this.resources.fetch({ type: 'order_factories' }, `order_subscriptions/${_orderSubscriptionId}/order_factories`, params, options);
46
+ }
47
+ async recurring_order_copies(orderSubscriptionId, params, options) {
32
48
  const _orderSubscriptionId = orderSubscriptionId.id || orderSubscriptionId;
33
- return this.resources.fetch({ type: 'order_copies' }, `order_subscriptions/${_orderSubscriptionId}/order_copies`, params, options);
49
+ return this.resources.fetch({ type: 'recurring_order_copies' }, `order_subscriptions/${_orderSubscriptionId}/recurring_order_copies`, params, options);
34
50
  }
35
51
  async orders(orderSubscriptionId, params, options) {
36
52
  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 OrderRel = ResourceRel & {
@@ -172,6 +174,7 @@ interface Order extends Resource {
172
174
  refreshed_at?: string;
173
175
  archived_at?: string;
174
176
  expires_at?: string;
177
+ subscription_created_at?: string;
175
178
  market?: Market;
176
179
  customer?: Customer;
177
180
  shipping_address?: Address;
@@ -191,7 +194,9 @@ interface Order extends Resource {
191
194
  refunds?: Refund[];
192
195
  returns?: Return[];
193
196
  order_subscriptions?: OrderSubscription[];
197
+ order_factories?: OrderFactory[];
194
198
  order_copies?: OrderCopy[];
199
+ recurring_order_copies?: RecurringOrderCopy[];
195
200
  attachments?: Attachment[];
196
201
  events?: Event[];
197
202
  }
@@ -254,6 +259,7 @@ interface OrderUpdate extends ResourceUpdate {
254
259
  _save_billing_address_to_customer_address_book?: boolean;
255
260
  _refresh?: boolean;
256
261
  _validate?: boolean;
262
+ _create_subscriptions?: boolean;
257
263
  market?: MarketRel;
258
264
  customer?: CustomerRel;
259
265
  shipping_address?: AddressRel;
@@ -285,7 +291,9 @@ declare class Orders extends ApiResource {
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;
@@ -84,10 +84,18 @@ class Orders extends ApiResource {
84
84
  const _orderId = orderId.id || orderId;
85
85
  return this.resources.fetch({ type: 'order_subscriptions' }, `orders/${_orderId}/order_subscriptions`, params, options);
86
86
  }
87
+ async order_factories(orderId, params, options) {
88
+ const _orderId = orderId.id || orderId;
89
+ return this.resources.fetch({ type: 'order_factories' }, `orders/${_orderId}/order_factories`, params, options);
90
+ }
87
91
  async order_copies(orderId, params, options) {
88
92
  const _orderId = orderId.id || orderId;
89
93
  return this.resources.fetch({ type: 'order_copies' }, `orders/${_orderId}/order_copies`, params, options);
90
94
  }
95
+ async recurring_order_copies(orderId, params, options) {
96
+ const _orderId = orderId.id || orderId;
97
+ return this.resources.fetch({ type: 'recurring_order_copies' }, `orders/${_orderId}/recurring_order_copies`, params, options);
98
+ }
91
99
  async attachments(orderId, params, options) {
92
100
  const _orderId = orderId.id || orderId;
93
101
  return this.resources.fetch({ type: 'attachments' }, `orders/${_orderId}/attachments`, params, options);
@@ -6,9 +6,9 @@ import type { OrderAmountPromotionRule } from './order_amount_promotion_rules';
6
6
  import type { SkuListPromotionRule } from './sku_list_promotion_rules';
7
7
  import type { CouponCodesPromotionRule } from './coupon_codes_promotion_rules';
8
8
  import type { Attachment } from './attachments';
9
+ import type { Event } from './events';
9
10
  import type { SkuList } from './sku_lists';
10
11
  import type { Sku } from './skus';
11
- import type { Event } from './events';
12
12
  type PercentageDiscountPromotionRel = ResourceRel & {
13
13
  type: typeof PercentageDiscountPromotions.TYPE;
14
14
  };
@@ -45,9 +45,9 @@ interface PercentageDiscountPromotion extends Resource {
45
45
  sku_list_promotion_rule?: SkuListPromotionRule;
46
46
  coupon_codes_promotion_rule?: CouponCodesPromotionRule;
47
47
  attachments?: Attachment[];
48
+ events?: Event[];
48
49
  sku_list?: SkuList;
49
50
  skus?: Sku[];
50
- events?: Event[];
51
51
  }
52
52
  interface PercentageDiscountPromotionCreate extends ResourceCreate {
53
53
  name: string;
@@ -89,9 +89,9 @@ declare class PercentageDiscountPromotions extends ApiResource {
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(): string;
@@ -36,6 +36,10 @@ class PercentageDiscountPromotions extends ApiResource {
36
36
  const _percentageDiscountPromotionId = percentageDiscountPromotionId.id || percentageDiscountPromotionId;
37
37
  return this.resources.fetch({ type: 'attachments' }, `percentage_discount_promotions/${_percentageDiscountPromotionId}/attachments`, params, options);
38
38
  }
39
+ async events(percentageDiscountPromotionId, params, options) {
40
+ const _percentageDiscountPromotionId = percentageDiscountPromotionId.id || percentageDiscountPromotionId;
41
+ return this.resources.fetch({ type: 'events' }, `percentage_discount_promotions/${_percentageDiscountPromotionId}/events`, params, options);
42
+ }
39
43
  async sku_list(percentageDiscountPromotionId, params, options) {
40
44
  const _percentageDiscountPromotionId = percentageDiscountPromotionId.id || percentageDiscountPromotionId;
41
45
  return this.resources.fetch({ type: 'sku_lists' }, `percentage_discount_promotions/${_percentageDiscountPromotionId}/sku_list`, params, options);
@@ -44,10 +48,6 @@ class PercentageDiscountPromotions extends ApiResource {
44
48
  const _percentageDiscountPromotionId = percentageDiscountPromotionId.id || percentageDiscountPromotionId;
45
49
  return this.resources.fetch({ type: 'skus' }, `percentage_discount_promotions/${_percentageDiscountPromotionId}/skus`, params, options);
46
50
  }
47
- async events(percentageDiscountPromotionId, params, options) {
48
- const _percentageDiscountPromotionId = percentageDiscountPromotionId.id || percentageDiscountPromotionId;
49
- return this.resources.fetch({ type: 'events' }, `percentage_discount_promotions/${_percentageDiscountPromotionId}/events`, params, options);
50
- }
51
51
  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
52
52
  isPercentageDiscountPromotion(resource) {
53
53
  return resource.type && (resource.type === PercentageDiscountPromotions.TYPE);
@@ -0,0 +1,49 @@
1
+ import { ApiResource, Resource, ResourceCreate, ResourceUpdate, ResourcesConfig, ResourceId, ResourceRel, ListResponse } from '../resource';
2
+ import type { QueryParamsList, QueryParamsRetrieve } from '../query';
3
+ import type { Price } from './prices';
4
+ import type { Attachment } from './attachments';
5
+ import type { Event } from './events';
6
+ type PriceFrequencyTierRel = ResourceRel & {
7
+ type: typeof PriceFrequencyTiers.TYPE;
8
+ };
9
+ type PriceRel = ResourceRel & {
10
+ type: 'prices';
11
+ };
12
+ interface PriceFrequencyTier extends Resource {
13
+ name?: string;
14
+ up_to?: number;
15
+ price_amount_cents?: number;
16
+ price_amount_float?: number;
17
+ formatted_price_amount?: string;
18
+ price?: Price;
19
+ attachments?: Attachment[];
20
+ events?: Event[];
21
+ }
22
+ interface PriceFrequencyTierCreate extends ResourceCreate {
23
+ name: string;
24
+ up_to?: number;
25
+ price_amount_cents: number;
26
+ price: PriceRel;
27
+ }
28
+ interface PriceFrequencyTierUpdate extends ResourceUpdate {
29
+ name?: string;
30
+ up_to?: number;
31
+ price_amount_cents?: number;
32
+ price?: PriceRel;
33
+ }
34
+ declare class PriceFrequencyTiers extends ApiResource {
35
+ static readonly TYPE: 'price_frequency_tiers';
36
+ list(params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<PriceFrequencyTier>>;
37
+ create(resource: PriceFrequencyTierCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<PriceFrequencyTier>;
38
+ retrieve(id: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<PriceFrequencyTier>;
39
+ update(resource: PriceFrequencyTierUpdate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<PriceFrequencyTier>;
40
+ delete(id: string, options?: ResourcesConfig): Promise<void>;
41
+ price(priceFrequencyTierId: string | PriceFrequencyTier, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Price>;
42
+ attachments(priceFrequencyTierId: string | PriceFrequencyTier, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Attachment>>;
43
+ events(priceFrequencyTierId: string | PriceFrequencyTier, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Event>>;
44
+ isPriceFrequencyTier(resource: any): resource is PriceFrequencyTier;
45
+ relationship(id: string | ResourceId | null): PriceFrequencyTierRel;
46
+ type(): string;
47
+ }
48
+ export default PriceFrequencyTiers;
49
+ export { PriceFrequencyTier, PriceFrequencyTierCreate, PriceFrequencyTierUpdate };