@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
@@ -0,0 +1,43 @@
1
+ import { ApiResource } from '../resource';
2
+ class PriceFrequencyTiers extends ApiResource {
3
+ // static readonly PATH = 'price_frequency_tiers'
4
+ async list(params, options) {
5
+ return this.resources.list({ type: PriceFrequencyTiers.TYPE }, params, options);
6
+ }
7
+ async create(resource, params, options) {
8
+ return this.resources.create(Object.assign(Object.assign({}, resource), { type: PriceFrequencyTiers.TYPE }), params, options);
9
+ }
10
+ async retrieve(id, params, options) {
11
+ return this.resources.retrieve({ type: PriceFrequencyTiers.TYPE, id }, params, options);
12
+ }
13
+ async update(resource, params, options) {
14
+ return this.resources.update(Object.assign(Object.assign({}, resource), { type: PriceFrequencyTiers.TYPE }), params, options);
15
+ }
16
+ async delete(id, options) {
17
+ await this.resources.delete({ type: PriceFrequencyTiers.TYPE, id }, options);
18
+ }
19
+ async price(priceFrequencyTierId, params, options) {
20
+ const _priceFrequencyTierId = priceFrequencyTierId.id || priceFrequencyTierId;
21
+ return this.resources.fetch({ type: 'prices' }, `price_frequency_tiers/${_priceFrequencyTierId}/price`, params, options);
22
+ }
23
+ async attachments(priceFrequencyTierId, params, options) {
24
+ const _priceFrequencyTierId = priceFrequencyTierId.id || priceFrequencyTierId;
25
+ return this.resources.fetch({ type: 'attachments' }, `price_frequency_tiers/${_priceFrequencyTierId}/attachments`, params, options);
26
+ }
27
+ async events(priceFrequencyTierId, params, options) {
28
+ const _priceFrequencyTierId = priceFrequencyTierId.id || priceFrequencyTierId;
29
+ return this.resources.fetch({ type: 'events' }, `price_frequency_tiers/${_priceFrequencyTierId}/events`, params, options);
30
+ }
31
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
32
+ isPriceFrequencyTier(resource) {
33
+ return resource.type && (resource.type === PriceFrequencyTiers.TYPE);
34
+ }
35
+ relationship(id) {
36
+ return ((id === null) || (typeof id === 'string')) ? { id, type: PriceFrequencyTiers.TYPE } : { id: id.id, type: PriceFrequencyTiers.TYPE };
37
+ }
38
+ type() {
39
+ return PriceFrequencyTiers.TYPE;
40
+ }
41
+ }
42
+ PriceFrequencyTiers.TYPE = 'price_frequency_tiers';
43
+ export default PriceFrequencyTiers;
@@ -2,6 +2,7 @@ import { ApiResource, Resource, ResourceCreate, ResourceUpdate, ResourcesConfig,
2
2
  import type { QueryParamsList, QueryParamsRetrieve } from '../query';
3
3
  import type { Price } from './prices';
4
4
  import type { Attachment } from './attachments';
5
+ import type { Event } from './events';
5
6
  type PriceVolumeTierRel = ResourceRel & {
6
7
  type: typeof PriceVolumeTiers.TYPE;
7
8
  };
@@ -16,6 +17,7 @@ interface PriceVolumeTier extends Resource {
16
17
  formatted_price_amount?: string;
17
18
  price?: Price;
18
19
  attachments?: Attachment[];
20
+ events?: Event[];
19
21
  }
20
22
  interface PriceVolumeTierCreate extends ResourceCreate {
21
23
  name: string;
@@ -38,6 +40,7 @@ declare class PriceVolumeTiers extends ApiResource {
38
40
  delete(id: string, options?: ResourcesConfig): Promise<void>;
39
41
  price(priceVolumeTierId: string | PriceVolumeTier, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Price>;
40
42
  attachments(priceVolumeTierId: string | PriceVolumeTier, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Attachment>>;
43
+ events(priceVolumeTierId: string | PriceVolumeTier, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Event>>;
41
44
  isPriceVolumeTier(resource: any): resource is PriceVolumeTier;
42
45
  relationship(id: string | ResourceId | null): PriceVolumeTierRel;
43
46
  type(): string;
@@ -24,6 +24,10 @@ class PriceVolumeTiers extends ApiResource {
24
24
  const _priceVolumeTierId = priceVolumeTierId.id || priceVolumeTierId;
25
25
  return this.resources.fetch({ type: 'attachments' }, `price_volume_tiers/${_priceVolumeTierId}/attachments`, params, options);
26
26
  }
27
+ async events(priceVolumeTierId, params, options) {
28
+ const _priceVolumeTierId = priceVolumeTierId.id || priceVolumeTierId;
29
+ return this.resources.fetch({ type: 'events' }, `price_volume_tiers/${_priceVolumeTierId}/events`, params, options);
30
+ }
27
31
  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
28
32
  isPriceVolumeTier(resource) {
29
33
  return resource.type && (resource.type === PriceVolumeTiers.TYPE);
@@ -4,6 +4,7 @@ import type { PriceList } from './price_lists';
4
4
  import type { Sku } from './skus';
5
5
  import type { PriceTier } from './price_tiers';
6
6
  import type { PriceVolumeTier } from './price_volume_tiers';
7
+ import type { PriceFrequencyTier } from './price_frequency_tiers';
7
8
  import type { Attachment } from './attachments';
8
9
  type PriceRel = ResourceRel & {
9
10
  type: typeof Prices.TYPE;
@@ -30,6 +31,7 @@ interface Price extends Resource {
30
31
  sku?: Sku;
31
32
  price_tiers?: PriceTier[];
32
33
  price_volume_tiers?: PriceVolumeTier[];
34
+ price_frequency_tiers?: PriceFrequencyTier[];
33
35
  attachments?: Attachment[];
34
36
  }
35
37
  interface PriceCreate extends ResourceCreate {
@@ -59,6 +61,7 @@ declare class Prices extends ApiResource {
59
61
  sku(priceId: string | Price, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Sku>;
60
62
  price_tiers(priceId: string | Price, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<PriceTier>>;
61
63
  price_volume_tiers(priceId: string | Price, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<PriceVolumeTier>>;
64
+ price_frequency_tiers(priceId: string | Price, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<PriceFrequencyTier>>;
62
65
  attachments(priceId: string | Price, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Attachment>>;
63
66
  isPrice(resource: any): resource is Price;
64
67
  relationship(id: string | ResourceId | null): PriceRel;
@@ -32,6 +32,10 @@ class Prices extends ApiResource {
32
32
  const _priceId = priceId.id || priceId;
33
33
  return this.resources.fetch({ type: 'price_volume_tiers' }, `prices/${_priceId}/price_volume_tiers`, params, options);
34
34
  }
35
+ async price_frequency_tiers(priceId, params, options) {
36
+ const _priceId = priceId.id || priceId;
37
+ return this.resources.fetch({ type: 'price_frequency_tiers' }, `prices/${_priceId}/price_frequency_tiers`, params, options);
38
+ }
35
39
  async attachments(priceId, params, options) {
36
40
  const _priceId = priceId.id || priceId;
37
41
  return this.resources.fetch({ type: 'attachments' }, `prices/${_priceId}/attachments`, params, options);
@@ -6,6 +6,7 @@ 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
  type PromotionRel = ResourceRel & {
10
11
  type: typeof Promotions.TYPE;
11
12
  };
@@ -23,6 +24,7 @@ interface Promotion extends Resource {
23
24
  sku_list_promotion_rule?: SkuListPromotionRule;
24
25
  coupon_codes_promotion_rule?: CouponCodesPromotionRule;
25
26
  attachments?: Attachment[];
27
+ events?: Event[];
26
28
  }
27
29
  declare class Promotions extends ApiResource {
28
30
  static readonly TYPE: 'promotions';
@@ -33,6 +35,7 @@ declare class Promotions extends ApiResource {
33
35
  sku_list_promotion_rule(promotionId: string | Promotion, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<SkuListPromotionRule>;
34
36
  coupon_codes_promotion_rule(promotionId: string | Promotion, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<CouponCodesPromotionRule>;
35
37
  attachments(promotionId: string | Promotion, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Attachment>>;
38
+ events(promotionId: string | Promotion, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Event>>;
36
39
  isPromotion(resource: any): resource is Promotion;
37
40
  relationship(id: string | ResourceId | null): PromotionRel;
38
41
  type(): string;
@@ -27,6 +27,10 @@ class Promotions extends ApiResource {
27
27
  const _promotionId = promotionId.id || promotionId;
28
28
  return this.resources.fetch({ type: 'attachments' }, `promotions/${_promotionId}/attachments`, params, options);
29
29
  }
30
+ async events(promotionId, params, options) {
31
+ const _promotionId = promotionId.id || promotionId;
32
+ return this.resources.fetch({ type: 'events' }, `promotions/${_promotionId}/events`, params, options);
33
+ }
30
34
  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
31
35
  isPromotion(resource) {
32
36
  return resource.type && (resource.type === Promotions.TYPE);
@@ -0,0 +1,52 @@
1
+ import { ApiResource, Resource, ResourceCreate, ResourceUpdate, 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
+ import type { OrderSubscription } from './order_subscriptions';
6
+ type RecurringOrderCopyRel = ResourceRel & {
7
+ type: typeof RecurringOrderCopies.TYPE;
8
+ };
9
+ type OrderRel = ResourceRel & {
10
+ type: 'orders';
11
+ };
12
+ type OrderSubscriptionRel = ResourceRel & {
13
+ type: 'order_subscriptions';
14
+ };
15
+ interface RecurringOrderCopy extends Resource {
16
+ status?: string;
17
+ started_at?: string;
18
+ completed_at?: string;
19
+ failed_at?: string;
20
+ errors_log?: object;
21
+ errors_count?: number;
22
+ place_target_order?: boolean;
23
+ reuse_wallet?: boolean;
24
+ source_order?: Order;
25
+ target_order?: Order;
26
+ events?: Event[];
27
+ order_subscription?: OrderSubscription;
28
+ }
29
+ interface RecurringOrderCopyCreate extends ResourceCreate {
30
+ place_target_order?: boolean;
31
+ reuse_wallet?: boolean;
32
+ source_order: OrderRel;
33
+ order_subscription: OrderSubscriptionRel;
34
+ }
35
+ type RecurringOrderCopyUpdate = ResourceUpdate;
36
+ declare class RecurringOrderCopies extends ApiResource {
37
+ static readonly TYPE: 'recurring_order_copies';
38
+ list(params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<RecurringOrderCopy>>;
39
+ create(resource: RecurringOrderCopyCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<RecurringOrderCopy>;
40
+ retrieve(id: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<RecurringOrderCopy>;
41
+ update(resource: RecurringOrderCopyUpdate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<RecurringOrderCopy>;
42
+ delete(id: string, options?: ResourcesConfig): Promise<void>;
43
+ source_order(recurringOrderCopyId: string | RecurringOrderCopy, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Order>;
44
+ target_order(recurringOrderCopyId: string | RecurringOrderCopy, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Order>;
45
+ events(recurringOrderCopyId: string | RecurringOrderCopy, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Event>>;
46
+ order_subscription(recurringOrderCopyId: string | RecurringOrderCopy, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<OrderSubscription>;
47
+ isRecurringOrderCopy(resource: any): resource is RecurringOrderCopy;
48
+ relationship(id: string | ResourceId | null): RecurringOrderCopyRel;
49
+ type(): string;
50
+ }
51
+ export default RecurringOrderCopies;
52
+ export { RecurringOrderCopy, RecurringOrderCopyCreate, RecurringOrderCopyUpdate };
@@ -0,0 +1,47 @@
1
+ import { ApiResource } from '../resource';
2
+ class RecurringOrderCopies extends ApiResource {
3
+ // static readonly PATH = 'recurring_order_copies'
4
+ async list(params, options) {
5
+ return this.resources.list({ type: RecurringOrderCopies.TYPE }, params, options);
6
+ }
7
+ async create(resource, params, options) {
8
+ return this.resources.create(Object.assign(Object.assign({}, resource), { type: RecurringOrderCopies.TYPE }), params, options);
9
+ }
10
+ async retrieve(id, params, options) {
11
+ return this.resources.retrieve({ type: RecurringOrderCopies.TYPE, id }, params, options);
12
+ }
13
+ async update(resource, params, options) {
14
+ return this.resources.update(Object.assign(Object.assign({}, resource), { type: RecurringOrderCopies.TYPE }), params, options);
15
+ }
16
+ async delete(id, options) {
17
+ await this.resources.delete({ type: RecurringOrderCopies.TYPE, id }, options);
18
+ }
19
+ async source_order(recurringOrderCopyId, params, options) {
20
+ const _recurringOrderCopyId = recurringOrderCopyId.id || recurringOrderCopyId;
21
+ return this.resources.fetch({ type: 'orders' }, `recurring_order_copies/${_recurringOrderCopyId}/source_order`, params, options);
22
+ }
23
+ async target_order(recurringOrderCopyId, params, options) {
24
+ const _recurringOrderCopyId = recurringOrderCopyId.id || recurringOrderCopyId;
25
+ return this.resources.fetch({ type: 'orders' }, `recurring_order_copies/${_recurringOrderCopyId}/target_order`, params, options);
26
+ }
27
+ async events(recurringOrderCopyId, params, options) {
28
+ const _recurringOrderCopyId = recurringOrderCopyId.id || recurringOrderCopyId;
29
+ return this.resources.fetch({ type: 'events' }, `recurring_order_copies/${_recurringOrderCopyId}/events`, params, options);
30
+ }
31
+ async order_subscription(recurringOrderCopyId, params, options) {
32
+ const _recurringOrderCopyId = recurringOrderCopyId.id || recurringOrderCopyId;
33
+ return this.resources.fetch({ type: 'order_subscriptions' }, `recurring_order_copies/${_recurringOrderCopyId}/order_subscription`, params, options);
34
+ }
35
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
36
+ isRecurringOrderCopy(resource) {
37
+ return resource.type && (resource.type === RecurringOrderCopies.TYPE);
38
+ }
39
+ relationship(id) {
40
+ return ((id === null) || (typeof id === 'string')) ? { id, type: RecurringOrderCopies.TYPE } : { id: id.id, type: RecurringOrderCopies.TYPE };
41
+ }
42
+ type() {
43
+ return RecurringOrderCopies.TYPE;
44
+ }
45
+ }
46
+ RecurringOrderCopies.TYPE = 'recurring_order_copies';
47
+ export default RecurringOrderCopies;
@@ -0,0 +1,48 @@
1
+ import { ApiResource, Resource, ResourceCreate, ResourceUpdate, ResourcesConfig, ResourceId, ResourceRel, ListResponse } from '../resource';
2
+ import type { QueryParamsList, QueryParamsRetrieve } from '../query';
3
+ import type { Market } from './markets';
4
+ import type { OrderSubscription } from './order_subscriptions';
5
+ import type { Attachment } from './attachments';
6
+ type SubscriptionModelRel = ResourceRel & {
7
+ type: typeof SubscriptionModels.TYPE;
8
+ };
9
+ interface SubscriptionModel extends Resource {
10
+ name?: string;
11
+ strategy?: string;
12
+ frequencies?: string[];
13
+ auto_activate?: boolean;
14
+ auto_cancel?: boolean;
15
+ markets?: Market[];
16
+ order_subscriptions?: OrderSubscription[];
17
+ attachments?: Attachment[];
18
+ }
19
+ interface SubscriptionModelCreate extends ResourceCreate {
20
+ name: string;
21
+ strategy?: string;
22
+ frequencies: string[];
23
+ auto_activate?: boolean;
24
+ auto_cancel?: boolean;
25
+ }
26
+ interface SubscriptionModelUpdate extends ResourceUpdate {
27
+ name?: string;
28
+ strategy?: string;
29
+ frequencies?: string[];
30
+ auto_activate?: boolean;
31
+ auto_cancel?: boolean;
32
+ }
33
+ declare class SubscriptionModels extends ApiResource {
34
+ static readonly TYPE: 'subscription_models';
35
+ list(params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<SubscriptionModel>>;
36
+ create(resource: SubscriptionModelCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<SubscriptionModel>;
37
+ retrieve(id: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<SubscriptionModel>;
38
+ update(resource: SubscriptionModelUpdate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<SubscriptionModel>;
39
+ delete(id: string, options?: ResourcesConfig): Promise<void>;
40
+ markets(subscriptionModelId: string | SubscriptionModel, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Market>>;
41
+ order_subscriptions(subscriptionModelId: string | SubscriptionModel, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<OrderSubscription>>;
42
+ attachments(subscriptionModelId: string | SubscriptionModel, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Attachment>>;
43
+ isSubscriptionModel(resource: any): resource is SubscriptionModel;
44
+ relationship(id: string | ResourceId | null): SubscriptionModelRel;
45
+ type(): string;
46
+ }
47
+ export default SubscriptionModels;
48
+ export { SubscriptionModel, SubscriptionModelCreate, SubscriptionModelUpdate };
@@ -0,0 +1,43 @@
1
+ import { ApiResource } from '../resource';
2
+ class SubscriptionModels extends ApiResource {
3
+ // static readonly PATH = 'subscription_models'
4
+ async list(params, options) {
5
+ return this.resources.list({ type: SubscriptionModels.TYPE }, params, options);
6
+ }
7
+ async create(resource, params, options) {
8
+ return this.resources.create(Object.assign(Object.assign({}, resource), { type: SubscriptionModels.TYPE }), params, options);
9
+ }
10
+ async retrieve(id, params, options) {
11
+ return this.resources.retrieve({ type: SubscriptionModels.TYPE, id }, params, options);
12
+ }
13
+ async update(resource, params, options) {
14
+ return this.resources.update(Object.assign(Object.assign({}, resource), { type: SubscriptionModels.TYPE }), params, options);
15
+ }
16
+ async delete(id, options) {
17
+ await this.resources.delete({ type: SubscriptionModels.TYPE, id }, options);
18
+ }
19
+ async markets(subscriptionModelId, params, options) {
20
+ const _subscriptionModelId = subscriptionModelId.id || subscriptionModelId;
21
+ return this.resources.fetch({ type: 'markets' }, `subscription_models/${_subscriptionModelId}/markets`, params, options);
22
+ }
23
+ async order_subscriptions(subscriptionModelId, params, options) {
24
+ const _subscriptionModelId = subscriptionModelId.id || subscriptionModelId;
25
+ return this.resources.fetch({ type: 'order_subscriptions' }, `subscription_models/${_subscriptionModelId}/order_subscriptions`, params, options);
26
+ }
27
+ async attachments(subscriptionModelId, params, options) {
28
+ const _subscriptionModelId = subscriptionModelId.id || subscriptionModelId;
29
+ return this.resources.fetch({ type: 'attachments' }, `subscription_models/${_subscriptionModelId}/attachments`, params, options);
30
+ }
31
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
32
+ isSubscriptionModel(resource) {
33
+ return resource.type && (resource.type === SubscriptionModels.TYPE);
34
+ }
35
+ relationship(id) {
36
+ return ((id === null) || (typeof id === 'string')) ? { id, type: SubscriptionModels.TYPE } : { id: id.id, type: SubscriptionModels.TYPE };
37
+ }
38
+ type() {
39
+ return SubscriptionModels.TYPE;
40
+ }
41
+ }
42
+ SubscriptionModels.TYPE = 'subscription_models';
43
+ export default SubscriptionModels;