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