@rechargeapps/storefront-client 1.17.3 → 1.18.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 (77) hide show
  1. package/dist/cjs/api/address.js +20 -10
  2. package/dist/cjs/api/address.js.map +1 -1
  3. package/dist/cjs/api/auth.js.map +1 -1
  4. package/dist/cjs/api/bundle.js +13 -8
  5. package/dist/cjs/api/bundle.js.map +1 -1
  6. package/dist/cjs/api/charge.js +22 -7
  7. package/dist/cjs/api/charge.js.map +1 -1
  8. package/dist/cjs/api/collection.js +88 -0
  9. package/dist/cjs/api/collection.js.map +1 -0
  10. package/dist/cjs/api/customer.js +17 -8
  11. package/dist/cjs/api/customer.js.map +1 -1
  12. package/dist/cjs/api/gift.js +2 -2
  13. package/dist/cjs/api/gift.js.map +1 -1
  14. package/dist/cjs/api/membership.js +15 -5
  15. package/dist/cjs/api/membership.js.map +1 -1
  16. package/dist/cjs/api/membershipProgram.js +7 -2
  17. package/dist/cjs/api/membershipProgram.js.map +1 -1
  18. package/dist/cjs/api/metafield.js +3 -3
  19. package/dist/cjs/api/metafield.js.map +1 -1
  20. package/dist/cjs/api/onetime.js +10 -5
  21. package/dist/cjs/api/onetime.js.map +1 -1
  22. package/dist/cjs/api/order.js +2 -2
  23. package/dist/cjs/api/order.js.map +1 -1
  24. package/dist/cjs/api/paymentMethod.js +9 -4
  25. package/dist/cjs/api/paymentMethod.js.map +1 -1
  26. package/dist/cjs/api/plan.js +2 -2
  27. package/dist/cjs/api/plan.js.map +1 -1
  28. package/dist/cjs/api/product.js +1 -1
  29. package/dist/cjs/api/product.js.map +1 -1
  30. package/dist/cjs/api/store.js +1 -1
  31. package/dist/cjs/api/store.js.map +1 -1
  32. package/dist/cjs/api/subscription.js +17 -12
  33. package/dist/cjs/api/subscription.js.map +1 -1
  34. package/dist/cjs/index.js +4 -0
  35. package/dist/cjs/index.js.map +1 -1
  36. package/dist/cjs/utils/request.js +11 -0
  37. package/dist/cjs/utils/request.js.map +1 -1
  38. package/dist/esm/api/address.js +21 -11
  39. package/dist/esm/api/address.js.map +1 -1
  40. package/dist/esm/api/auth.js.map +1 -1
  41. package/dist/esm/api/bundle.js +13 -8
  42. package/dist/esm/api/bundle.js.map +1 -1
  43. package/dist/esm/api/charge.js +23 -8
  44. package/dist/esm/api/charge.js.map +1 -1
  45. package/dist/esm/api/collection.js +84 -0
  46. package/dist/esm/api/collection.js.map +1 -0
  47. package/dist/esm/api/customer.js +18 -9
  48. package/dist/esm/api/customer.js.map +1 -1
  49. package/dist/esm/api/gift.js +3 -3
  50. package/dist/esm/api/gift.js.map +1 -1
  51. package/dist/esm/api/membership.js +16 -6
  52. package/dist/esm/api/membership.js.map +1 -1
  53. package/dist/esm/api/membershipProgram.js +8 -3
  54. package/dist/esm/api/membershipProgram.js.map +1 -1
  55. package/dist/esm/api/metafield.js +4 -4
  56. package/dist/esm/api/metafield.js.map +1 -1
  57. package/dist/esm/api/onetime.js +11 -6
  58. package/dist/esm/api/onetime.js.map +1 -1
  59. package/dist/esm/api/order.js +3 -3
  60. package/dist/esm/api/order.js.map +1 -1
  61. package/dist/esm/api/paymentMethod.js +10 -5
  62. package/dist/esm/api/paymentMethod.js.map +1 -1
  63. package/dist/esm/api/plan.js +3 -3
  64. package/dist/esm/api/plan.js.map +1 -1
  65. package/dist/esm/api/product.js +2 -2
  66. package/dist/esm/api/product.js.map +1 -1
  67. package/dist/esm/api/store.js +2 -2
  68. package/dist/esm/api/store.js.map +1 -1
  69. package/dist/esm/api/subscription.js +18 -13
  70. package/dist/esm/api/subscription.js.map +1 -1
  71. package/dist/esm/index.js +1 -0
  72. package/dist/esm/index.js.map +1 -1
  73. package/dist/esm/utils/request.js +11 -1
  74. package/dist/esm/utils/request.js.map +1 -1
  75. package/dist/index.d.ts +111 -74
  76. package/dist/umd/recharge-client.min.js +11 -11
  77. package/package.json +2 -2
@@ -1,5 +1,5 @@
1
1
  import partial from 'lodash.partial';
2
- import { rechargeApiRequest } from '../utils/request.js';
2
+ import { rechargeApiRequest, getInternalSession } from '../utils/request.js';
3
3
  import { bulkSubscriptionCreateMapper, subscriptionMapperOldToNew, bulkSubscriptionUpdateMapper } from '../mappers/subscription.js';
4
4
 
5
5
  async function getSubscription(session, id, options) {
@@ -10,12 +10,17 @@ async function getSubscription(session, id, options) {
10
10
  id,
11
11
  query: { include: options?.include }
12
12
  },
13
- session
13
+ getInternalSession(session, "getSubscription")
14
14
  );
15
15
  return subscription;
16
16
  }
17
17
  function listSubscriptions(session, query) {
18
- return rechargeApiRequest("get", `/subscriptions`, { query }, session);
18
+ return rechargeApiRequest(
19
+ "get",
20
+ `/subscriptions`,
21
+ { query },
22
+ getInternalSession(session, "listSubscriptions")
23
+ );
19
24
  }
20
25
  async function createSubscription(session, createRequest, query) {
21
26
  const { subscription } = await rechargeApiRequest(
@@ -25,7 +30,7 @@ async function createSubscription(session, createRequest, query) {
25
30
  data: createRequest,
26
31
  query
27
32
  },
28
- session
33
+ getInternalSession(session, "createSubscription")
29
34
  );
30
35
  return subscription;
31
36
  }
@@ -38,7 +43,7 @@ async function updateSubscription(session, id, updateRequest, query) {
38
43
  data: updateRequest,
39
44
  query
40
45
  },
41
- session
46
+ getInternalSession(session, "updateSubscription")
42
47
  );
43
48
  return subscription;
44
49
  }
@@ -50,7 +55,7 @@ async function updateSubscriptionChargeDate(session, id, date, query) {
50
55
  data: { date },
51
56
  query
52
57
  },
53
- session
58
+ getInternalSession(session, "updateSubscriptionChargeDate")
54
59
  );
55
60
  return subscription;
56
61
  }
@@ -61,7 +66,7 @@ async function updateSubscriptionAddress(session, id, address_id) {
61
66
  {
62
67
  data: { address_id }
63
68
  },
64
- session
69
+ getInternalSession(session, "updateSubscriptionAddress")
65
70
  );
66
71
  return subscription;
67
72
  }
@@ -73,7 +78,7 @@ async function cancelSubscription(session, id, cancelRequest, query) {
73
78
  data: cancelRequest,
74
79
  query
75
80
  },
76
- session
81
+ getInternalSession(session, "cancelSubscription")
77
82
  );
78
83
  return subscription;
79
84
  }
@@ -82,7 +87,7 @@ async function activateSubscription(session, id, query) {
82
87
  "post",
83
88
  `/subscriptions/${id}/activate`,
84
89
  { query },
85
- session
90
+ getInternalSession(session, "activateSubscription")
86
91
  );
87
92
  return subscription;
88
93
  }
@@ -96,7 +101,7 @@ async function skipSubscriptionCharge(session, id, date) {
96
101
  subscription_id: `${id}`
97
102
  }
98
103
  },
99
- session
104
+ getInternalSession(session, "skipSubscriptionCharge")
100
105
  );
101
106
  return charge;
102
107
  }
@@ -110,7 +115,7 @@ async function skipGiftSubscriptionCharge(session, subscriptionIds, recipientAdd
110
115
  recipient_address: recipientAddress
111
116
  }
112
117
  },
113
- session
118
+ getInternalSession(session, "skipGiftSubscriptionCharge")
114
119
  );
115
120
  return onetimes;
116
121
  }
@@ -138,7 +143,7 @@ async function createSubscriptions(session, createRequestBulk) {
138
143
  "X-Recharge-Version": "2021-01"
139
144
  }
140
145
  },
141
- session
146
+ getInternalSession(session, "createSubscriptions")
142
147
  );
143
148
  return subscriptions.map(subscriptionMapperOldToNew);
144
149
  }
@@ -162,7 +167,7 @@ async function updateSubscriptions(session, addressId, updateRequestBulk, query)
162
167
  "X-Recharge-Version": "2021-01"
163
168
  }
164
169
  },
165
- session
170
+ getInternalSession(session, "updateSubscriptions")
166
171
  );
167
172
  return subscriptions.map(subscriptionMapperOldToNew);
168
173
  }
@@ -1 +1 @@
1
- {"version":3,"file":"subscription.js","sources":["../../../src/api/subscription.ts"],"sourcesContent":["import partial from 'lodash.partial';\nimport { rechargeApiRequest } from '../utils/request';\nimport {\n CancelSubscriptionRequest,\n CreateSubscriptionRequest,\n Subscription,\n SubscriptionsResponse,\n SubscriptionListParams,\n UpdateSubscriptionRequest,\n UpdateSubscriptionParams,\n GetSubscriptionOptions,\n BasicSubscriptionParams,\n Subscription_2021_01,\n UpdateSubscriptionsRequest,\n UpdateSubscriptionsParams,\n} from '../types/subscription';\nimport { IsoDateString } from '../types/common';\nimport { Session } from '../types/session';\nimport { ChargeResponse, CreateRecipientAddress, Onetime } from '../types';\nimport {\n bulkSubscriptionCreateMapper,\n bulkSubscriptionUpdateMapper,\n subscriptionMapperOldToNew,\n} from '../mappers/subscription';\n\nexport async function getSubscription(\n session: Session,\n id: string | number,\n options?: GetSubscriptionOptions\n): Promise<Subscription> {\n const { subscription } = await rechargeApiRequest<{ subscription: Subscription }>(\n 'get',\n `/subscriptions`,\n {\n id,\n query: { include: options?.include },\n },\n session\n );\n return subscription;\n}\n\nexport function listSubscriptions(session: Session, query?: SubscriptionListParams): Promise<SubscriptionsResponse> {\n return rechargeApiRequest<SubscriptionsResponse>('get', `/subscriptions`, { query }, session);\n}\n\n/**\n * When creating a subscription via API, order_interval_frequency and charge_interval_frequency values do not necessarily\n * need to match the values set in the respective Plans. The product, however, does need to have at least one Plan in order\n * to be added to a subscription.\n */\nexport async function createSubscription(\n session: Session,\n createRequest: CreateSubscriptionRequest,\n query?: BasicSubscriptionParams\n): Promise<Subscription> {\n const { subscription } = await rechargeApiRequest<{ subscription: Subscription }>(\n 'post',\n `/subscriptions`,\n {\n data: createRequest,\n query,\n },\n session\n );\n return subscription;\n}\n\n/**\n * Updating parameters like frequency, charge_interval_frequency, order_interval_frequency, order_interval_unit will cause our algorithm to automatically recalculate the next charge date (next_charge_scheduled_at).\n * WARNING: This update will remove skipped and manually changed charges.\n * If you want to change the next charge date (next_charge_scheduled_at) we recommend you to update these parameters first.\n * When updating order_interval_unit OR order_interval_frequency OR charge_interval_frequency all three parameters are required.\n */\nexport async function updateSubscription(\n session: Session,\n id: string | number,\n updateRequest: UpdateSubscriptionRequest,\n query?: UpdateSubscriptionParams\n): Promise<Subscription> {\n const { subscription } = await rechargeApiRequest<{ subscription: Subscription }>(\n 'put',\n `/subscriptions`,\n {\n id,\n data: updateRequest,\n query,\n },\n session\n );\n return subscription;\n}\n\n/**\n * If there are two active subscriptions with the same address_id, and you update their\n * next_charge_date parameters to match, their charges will get merged into a new charge\n * with a new id\n */\nexport async function updateSubscriptionChargeDate(\n session: Session,\n id: string | number,\n date: IsoDateString,\n query?: BasicSubscriptionParams\n): Promise<Subscription> {\n const { subscription } = await rechargeApiRequest<{ subscription: Subscription }>(\n 'post',\n `/subscriptions/${id}/set_next_charge_date`,\n {\n data: { date },\n query,\n },\n session\n );\n return subscription;\n}\n\nexport async function updateSubscriptionAddress(\n session: Session,\n id: string | number,\n address_id: string | number\n): Promise<Subscription> {\n const { subscription } = await rechargeApiRequest<{ subscription: Subscription }>(\n 'post',\n `/subscriptions/${id}/change_address`,\n {\n data: { address_id },\n },\n session\n );\n return subscription;\n}\n\n/**\n * An involuntary subscription cancelled due to max retries reached will trigger the\n * charge/max_retries_reached webhook. If this leads to the subscription being cancelled,\n * the subscription/cancelled webhook will trigger.\n */\nexport async function cancelSubscription(\n session: Session,\n id: string | number,\n cancelRequest: CancelSubscriptionRequest,\n query?: BasicSubscriptionParams\n): Promise<Subscription> {\n const { subscription } = await rechargeApiRequest<{ subscription: Subscription }>(\n 'post',\n `/subscriptions/${id}/cancel`,\n {\n data: cancelRequest,\n query,\n },\n session\n );\n return subscription;\n}\n\n/**\n * When activating subscription, following attributes will be set to null: cancelled_at, cancellation_reason\n * and cancellation_reason_comments.\n */\nexport async function activateSubscription(\n session: Session,\n id: string | number,\n query?: BasicSubscriptionParams\n): Promise<Subscription> {\n const { subscription } = await rechargeApiRequest<{ subscription: Subscription }>(\n 'post',\n `/subscriptions/${id}/activate`,\n { query },\n session\n );\n return subscription;\n}\n\n/* Skip charge associated with a subscription. */\nexport async function skipSubscriptionCharge(session: Session, id: number | string, date: IsoDateString) {\n const { charge } = await rechargeApiRequest<ChargeResponse>(\n 'post',\n `/subscriptions/${id}/charges/skip`,\n {\n data: {\n date,\n subscription_id: `${id}`,\n },\n },\n session\n );\n return charge;\n}\n\n/**\n * Gift a subscription to another person. This creates onetime products for the recipient and skips that subscription for the customer.\n * When the gifted onetime ships the recipient receives and email notification.\n */\nexport async function skipGiftSubscriptionCharge(\n session: Session,\n subscriptionIds: Array<number | string>,\n recipientAddress: CreateRecipientAddress\n) {\n const { onetimes } = await rechargeApiRequest<{ onetimes: Onetime[] }>(\n 'post',\n '/purchase_items/skip_gift',\n {\n data: {\n purchase_item_ids: subscriptionIds.map(Number),\n recipient_address: recipientAddress,\n },\n },\n session\n );\n\n return onetimes;\n}\n\n/**\n * Bulk create new subscriptions.\n * Must all be for the same address.\n * There is a limit of 20 subscriptions per request.\n */\nexport async function createSubscriptions(\n session: Session,\n createRequestBulk: CreateSubscriptionRequest[]\n): Promise<Subscription[]> {\n // validate size\n const length = createRequestBulk.length;\n if (length < 1 || length > 21) {\n throw new Error('Number of subscriptions must be between 1 and 20.');\n }\n // validate customerId\n const { customerId } = session;\n if (!customerId) {\n throw new Error('No customerId in session.');\n }\n // validate addressId\n const addressId = createRequestBulk[0].address_id;\n if (!createRequestBulk.every(createRequest => createRequest.address_id === addressId)) {\n throw new Error('All subscriptions must have the same address_id.');\n }\n const bulkSubscriptionMapperPartial = partial(bulkSubscriptionCreateMapper, customerId);\n const requestData = createRequestBulk.map(bulkSubscriptionMapperPartial);\n const { subscriptions } = await rechargeApiRequest<{ subscriptions: Subscription_2021_01[] }>(\n 'post',\n `/addresses/${addressId}/subscriptions-bulk`,\n {\n data: { subscriptions: requestData },\n headers: {\n 'X-Recharge-Version': '2021-01',\n },\n },\n session\n );\n return subscriptions.map(subscriptionMapperOldToNew);\n}\n\n/**\n * Bulk create new subscriptions.\n * Must all be for the same address.\n * There is a limit of 20 subscriptions per request.\n * Same rules apply as a single subscription update\n */\nexport async function updateSubscriptions(\n session: Session,\n addressId: string | number,\n updateRequestBulk: UpdateSubscriptionsRequest[],\n query?: UpdateSubscriptionsParams\n): Promise<Subscription[]> {\n // validate size\n const length = updateRequestBulk.length;\n if (length < 1 || length > 21) {\n throw new Error('Number of subscriptions must be between 1 and 20.');\n }\n // validate customerId\n const { customerId } = session;\n if (!customerId) {\n throw new Error('No customerId in session.');\n }\n const bulkSubscriptionMapperPartial = partial(bulkSubscriptionUpdateMapper, !!query?.force_update);\n const requestData = updateRequestBulk.map(bulkSubscriptionMapperPartial);\n const { subscriptions } = await rechargeApiRequest<{ subscriptions: Subscription_2021_01[] }>(\n 'put',\n `/addresses/${addressId}/subscriptions-bulk`,\n {\n data: { subscriptions: requestData },\n headers: {\n 'X-Recharge-Version': '2021-01',\n },\n },\n session\n );\n return subscriptions.map(subscriptionMapperOldToNew);\n}\n"],"names":[],"mappings":";;;;AAyBsB,eAAA,eAAA,CACpB,OACA,EAAA,EAAA,EACA,OACuB,EAAA;AACvB,EAAM,MAAA,EAAE,YAAa,EAAA,GAAI,MAAM,kBAAA;AAAA,IAC7B,KAAA;AAAA,IACA,CAAA,cAAA,CAAA;AAAA,IACA;AAAA,MACE,EAAA;AAAA,MACA,KAAO,EAAA,EAAE,OAAS,EAAA,OAAA,EAAS,OAAQ,EAAA;AAAA,KACrC;AAAA,IACA,OAAA;AAAA,GACF,CAAA;AACA,EAAO,OAAA,YAAA,CAAA;AACT,CAAA;AAEgB,SAAA,iBAAA,CAAkB,SAAkB,KAAgE,EAAA;AAClH,EAAA,OAAO,mBAA0C,KAAO,EAAA,CAAA,cAAA,CAAA,EAAkB,EAAE,KAAA,IAAS,OAAO,CAAA,CAAA;AAC9F,CAAA;AAOsB,eAAA,kBAAA,CACpB,OACA,EAAA,aAAA,EACA,KACuB,EAAA;AACvB,EAAM,MAAA,EAAE,YAAa,EAAA,GAAI,MAAM,kBAAA;AAAA,IAC7B,MAAA;AAAA,IACA,CAAA,cAAA,CAAA;AAAA,IACA;AAAA,MACE,IAAM,EAAA,aAAA;AAAA,MACN,KAAA;AAAA,KACF;AAAA,IACA,OAAA;AAAA,GACF,CAAA;AACA,EAAO,OAAA,YAAA,CAAA;AACT,CAAA;AAQA,eAAsB,kBACpB,CAAA,OAAA,EACA,EACA,EAAA,aAAA,EACA,KACuB,EAAA;AACvB,EAAM,MAAA,EAAE,YAAa,EAAA,GAAI,MAAM,kBAAA;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Y,EAAA;AACf,IAAM,MAAA,IAAI,MAAM,2BAA2B,CAAA,CAAA;AAAA,GAC7C;AACA,EAAA,MAAM,gCAAgC,OAAQ,CAAA,4BAAA,EAA8B,CAAC,CAAC,OAAO,YAAY,CAAA,CAAA;AACjG,EAAM,MAAA,WAAA,GAAc,iBAAkB,CAAA,GAAA,CAAI,6BAA6B,CAAA,CAAA;AACvE,EAAM,MAAA,EAAE,aAAc,EAAA,GAAI,MAAM,kBAAA;AAAA,IAC9B,KAAA;AAAA,IACA,cAAc,SAAS,CAAA,mBAAA,CAAA;AAAA,IACvB;AAAA,MACE,IAAA,EAAM,EAAE,aAAA,EAAe,WAAY,EAAA;AAAA,MACnC,OAAS,EAAA;AAAA,QACP,oBAAsB,EAAA,SAAA;AAAA,OACxB;AAAA,KACF;AAAA,IACA,OAAA;AAAA,GACF,CAAA;AACA,EAAO,OAAA,aAAA,CAAc,IAAI,0BAA0B,CAAA,CAAA;AACrD;;;;"}
1
+ {"version":3,"file":"subscription.js","sources":["../../../src/api/subscription.ts"],"sourcesContent":["import partial from 'lodash.partial';\nimport { getInternalSession, rechargeApiRequest } from '../utils/request';\nimport {\n CancelSubscriptionRequest,\n CreateSubscriptionRequest,\n Subscription,\n SubscriptionsResponse,\n SubscriptionListParams,\n UpdateSubscriptionRequest,\n UpdateSubscriptionParams,\n GetSubscriptionOptions,\n BasicSubscriptionParams,\n Subscription_2021_01,\n UpdateSubscriptionsRequest,\n UpdateSubscriptionsParams,\n Session,\n ChargeResponse,\n CreateRecipientAddress,\n Onetime,\n IsoDateString,\n} from '../types';\nimport {\n bulkSubscriptionCreateMapper,\n bulkSubscriptionUpdateMapper,\n subscriptionMapperOldToNew,\n} from '../mappers/subscription';\n\nexport async function getSubscription(\n session: Session,\n id: string | number,\n options?: GetSubscriptionOptions\n): Promise<Subscription> {\n const { subscription } = await rechargeApiRequest<{ subscription: Subscription }>(\n 'get',\n `/subscriptions`,\n {\n id,\n query: { include: options?.include },\n },\n getInternalSession(session, 'getSubscription')\n );\n return subscription;\n}\n\nexport function listSubscriptions(session: Session, query?: SubscriptionListParams): Promise<SubscriptionsResponse> {\n return rechargeApiRequest<SubscriptionsResponse>(\n 'get',\n `/subscriptions`,\n { query },\n getInternalSession(session, 'listSubscriptions')\n );\n}\n\n/**\n * When creating a subscription via API, order_interval_frequency and charge_interval_frequency values do not necessarily\n * need to match the values set in the respective Plans. The product, however, does need to have at least one Plan in order\n * to be added to a subscription.\n */\nexport async function createSubscription(\n session: Session,\n createRequest: CreateSubscriptionRequest,\n query?: BasicSubscriptionParams\n): Promise<Subscription> {\n const { subscription } = await rechargeApiRequest<{ subscription: Subscription }>(\n 'post',\n `/subscriptions`,\n {\n data: createRequest,\n query,\n },\n getInternalSession(session, 'createSubscription')\n );\n return subscription;\n}\n\n/**\n * Updating parameters like frequency, charge_interval_frequency, order_interval_frequency, order_interval_unit will cause our algorithm to automatically recalculate the next charge date (next_charge_scheduled_at).\n * WARNING: This update will remove skipped and manually changed charges.\n * If you want to change the next charge date (next_charge_scheduled_at) we recommend you to update these parameters first.\n * When updating order_interval_unit OR order_interval_frequency OR charge_interval_frequency all three parameters are required.\n */\nexport async function updateSubscription(\n session: Session,\n id: string | number,\n updateRequest: UpdateSubscriptionRequest,\n query?: UpdateSubscriptionParams\n): Promise<Subscription> {\n const { subscription } = await rechargeApiRequest<{ subscription: Subscription }>(\n 'put',\n `/subscriptions`,\n {\n id,\n data: updateRequest,\n query,\n },\n getInternalSession(session, 'updateSubscription')\n );\n return subscription;\n}\n\n/**\n * If there are two active subscriptions with the same address_id, and you update their\n * next_charge_date parameters to match, their charges will get merged into a new charge\n * with a new id\n */\nexport async function updateSubscriptionChargeDate(\n session: Session,\n id: string | number,\n date: IsoDateString,\n query?: BasicSubscriptionParams\n): Promise<Subscription> {\n const { subscription } = await rechargeApiRequest<{ subscription: Subscription }>(\n 'post',\n `/subscriptions/${id}/set_next_charge_date`,\n {\n data: { date },\n query,\n },\n getInternalSession(session, 'updateSubscriptionChargeDate')\n );\n return subscription;\n}\n\nexport async function updateSubscriptionAddress(\n session: Session,\n id: string | number,\n address_id: string | number\n): Promise<Subscription> {\n const { subscription } = await rechargeApiRequest<{ subscription: Subscription }>(\n 'post',\n `/subscriptions/${id}/change_address`,\n {\n data: { address_id },\n },\n getInternalSession(session, 'updateSubscriptionAddress')\n );\n return subscription;\n}\n\n/**\n * An involuntary subscription cancelled due to max retries reached will trigger the\n * charge/max_retries_reached webhook. If this leads to the subscription being cancelled,\n * the subscription/cancelled webhook will trigger.\n */\nexport async function cancelSubscription(\n session: Session,\n id: string | number,\n cancelRequest: CancelSubscriptionRequest,\n query?: BasicSubscriptionParams\n): Promise<Subscription> {\n const { subscription } = await rechargeApiRequest<{ subscription: Subscription }>(\n 'post',\n `/subscriptions/${id}/cancel`,\n {\n data: cancelRequest,\n query,\n },\n getInternalSession(session, 'cancelSubscription')\n );\n return subscription;\n}\n\n/**\n * When activating subscription, following attributes will be set to null: cancelled_at, cancellation_reason\n * and cancellation_reason_comments.\n */\nexport async function activateSubscription(\n session: Session,\n id: string | number,\n query?: BasicSubscriptionParams\n): Promise<Subscription> {\n const { subscription } = await rechargeApiRequest<{ subscription: Subscription }>(\n 'post',\n `/subscriptions/${id}/activate`,\n { query },\n getInternalSession(session, 'activateSubscription')\n );\n return subscription;\n}\n\n/* Skip charge associated with a subscription. */\nexport async function skipSubscriptionCharge(session: Session, id: number | string, date: IsoDateString) {\n const { charge } = await rechargeApiRequest<ChargeResponse>(\n 'post',\n `/subscriptions/${id}/charges/skip`,\n {\n data: {\n date,\n subscription_id: `${id}`,\n },\n },\n getInternalSession(session, 'skipSubscriptionCharge')\n );\n return charge;\n}\n\n/**\n * Gift a subscription to another person. This creates onetime products for the recipient and skips that subscription for the customer.\n * When the gifted onetime ships the recipient receives and email notification.\n */\nexport async function skipGiftSubscriptionCharge(\n session: Session,\n subscriptionIds: Array<number | string>,\n recipientAddress: CreateRecipientAddress\n) {\n const { onetimes } = await rechargeApiRequest<{ onetimes: Onetime[] }>(\n 'post',\n '/purchase_items/skip_gift',\n {\n data: {\n purchase_item_ids: subscriptionIds.map(Number),\n recipient_address: recipientAddress,\n },\n },\n getInternalSession(session, 'skipGiftSubscriptionCharge')\n );\n\n return onetimes;\n}\n\n/**\n * Bulk create new subscriptions.\n * Must all be for the same address.\n * There is a limit of 20 subscriptions per request.\n */\nexport async function createSubscriptions(\n session: Session,\n createRequestBulk: CreateSubscriptionRequest[]\n): Promise<Subscription[]> {\n // validate size\n const length = createRequestBulk.length;\n if (length < 1 || length > 21) {\n throw new Error('Number of subscriptions must be between 1 and 20.');\n }\n // validate customerId\n const { customerId } = session;\n if (!customerId) {\n throw new Error('No customerId in session.');\n }\n // validate addressId\n const addressId = createRequestBulk[0].address_id;\n if (!createRequestBulk.every(createRequest => createRequest.address_id === addressId)) {\n throw new Error('All subscriptions must have the same address_id.');\n }\n const bulkSubscriptionMapperPartial = partial(bulkSubscriptionCreateMapper, customerId);\n const requestData = createRequestBulk.map(bulkSubscriptionMapperPartial);\n const { subscriptions } = await rechargeApiRequest<{ subscriptions: Subscription_2021_01[] }>(\n 'post',\n `/addresses/${addressId}/subscriptions-bulk`,\n {\n data: { subscriptions: requestData },\n headers: {\n 'X-Recharge-Version': '2021-01',\n },\n },\n getInternalSession(session, 'createSubscriptions')\n );\n return subscriptions.map(subscriptionMapperOldToNew);\n}\n\n/**\n * Bulk create new subscriptions.\n * Must all be for the same address.\n * There is a limit of 20 subscriptions per request.\n * Same rules apply as a single subscription update\n */\nexport async function updateSubscriptions(\n session: Session,\n addressId: string | number,\n updateRequestBulk: UpdateSubscriptionsRequest[],\n query?: UpdateSubscriptionsParams\n): Promise<Subscription[]> {\n // validate size\n const length = updateRequestBulk.length;\n if (length < 1 || length > 21) {\n throw new Error('Number of subscriptions must be between 1 and 20.');\n }\n // validate customerId\n const { customerId } = session;\n if (!customerId) {\n throw new Error('No customerId in session.');\n }\n const bulkSubscriptionMapperPartial = partial(bulkSubscriptionUpdateMapper, !!query?.force_update);\n const requestData = updateRequestBulk.map(bulkSubscriptionMapperPartial);\n const { subscriptions } = await rechargeApiRequest<{ subscriptions: Subscription_2021_01[] }>(\n 'put',\n `/addresses/${addressId}/subscriptions-bulk`,\n {\n data: { subscriptions: requestData },\n headers: {\n 'X-Recharge-Version': '2021-01',\n },\n },\n getInternalSession(session, 'updateSubscriptions')\n );\n return subscriptions.map(subscriptionMapperOldToNew);\n}\n"],"names":[],"mappings":";;;;AA2BsB,eAAA,eAAA,CACpB,OACA,EAAA,EAAA,EACA,OACuB,EAAA;AACvB,EAAM,MAAA,EAAE,YAAa,EAAA,GAAI,MAAM,kBAAA;AAAA,IAC7B,KAAA;AAAA,IACA,CAAA,cAAA,CAAA;AAAA,IACA;AAAA,MACE,EAAA;AAAA,MACA,KAAO,EAAA,EAAE,OAAS,EAAA,OAAA,EAAS,OAAQ,EAAA;AAAA,KACrC;AAAA,IACA,kBAAA,CAAmB,SAAS,iBAAiB,CAAA;AAAA,GAC/C,CAAA;AACA,EAAO,OAAA,YAAA,CAAA;AACT,CAAA;AAEgB,SAAA,iBAAA,CAAkB,SAAkB,KAAgE,EAAA;AAClH,EAAO,OAAA,kBAAA;AAAA,IACL,KAAA;AAAA,IACA,CAAA,cAAA,CAAA;AAAA,IACA,EAAE,KAAM,EAAA;AAAA,IACR,kBAAA,CAAmB,SAAS,mBAAmB,CAAA;AAAA,GACjD,CAAA;AACF,CAAA;AAOsB,eAAA,kBAAA,CACpB,OACA,EAAA,aAAA,EACA,KACuB,EAAA;AACvB,EAAM,MAAA,EAAE,YAAa,EAAA,GAAI,MAAM,kBAAA;AAAA,IAC7B,MAAA;AAAA,IACA,CAAA,cAAA,CAAA;AAAA,IACA;AAAA,MACE,IAAM,EAAA,aAAA;AAAA,MACN,KAAA;AAAA,KACF;AAAA,IACA,kBAAA,CAAmB,SAAS,oBAAoB,CAAA;AAAA,GAClD,CAAA;AACA,EAAO,OAAA,YAAA,CAAA;AACT,CAAA;AAQA,eAAs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A0B,CAAA,CAAA;AACrD,CAAA;AAQA,eAAsB,mBACpB,CAAA,OAAA,EACA,SACA,EAAA,iBAAA,EACA,KACyB,EAAA;AAEzB,EAAA,MAAM,SAAS,iBAAkB,CAAA,MAAA,CAAA;AACjC,EAAI,IAAA,MAAA,GAAS,CAAK,IAAA,MAAA,GAAS,EAAI,EAAA;AAC7B,IAAM,MAAA,IAAI,MAAM,mDAAmD,CAAA,CAAA;AAAA,GACrE;AAEA,EAAM,MAAA,EAAE,YAAe,GAAA,OAAA,CAAA;AACvB,EAAA,IAAI,CAAC,UAAY,EAAA;AACf,IAAM,MAAA,IAAI,MAAM,2BAA2B,CAAA,CAAA;AAAA,GAC7C;AACA,EAAA,MAAM,gCAAgC,OAAQ,CAAA,4BAAA,EAA8B,CAAC,CAAC,OAAO,YAAY,CAAA,CAAA;AACjG,EAAM,MAAA,WAAA,GAAc,iBAAkB,CAAA,GAAA,CAAI,6BAA6B,CAAA,CAAA;AACvE,EAAM,MAAA,EAAE,aAAc,EAAA,GAAI,MAAM,kBAAA;AAAA,IAC9B,KAAA;AAAA,IACA,cAAc,SAAS,CAAA,mBAAA,CAAA;AAAA,IACvB;AAAA,MACE,IAAA,EAAM,EAAE,aAAA,EAAe,WAAY,EAAA;AAAA,MACnC,OAAS,EAAA;AAAA,QACP,oBAAsB,EAAA,SAAA;AAAA,OACxB;AAAA,KACF;AAAA,IACA,kBAAA,CAAmB,SAAS,qBAAqB,CAAA;AAAA,GACnD,CAAA;AACA,EAAO,OAAA,aAAA,CAAc,IAAI,0BAA0B,CAAA,CAAA;AACrD;;;;"}
package/dist/esm/index.js CHANGED
@@ -3,6 +3,7 @@ export { loginCustomerPortal, loginShopifyApi, loginShopifyAppProxy, loginWithSh
3
3
  export { createBundleSelection, deleteBundleSelection, getBundleId, getBundleSelection, getDynamicBundleItems, listBundleSelections, updateBundle, updateBundleSelection, validateBundle, validateDynamicBundle } from './api/bundle.js';
4
4
  export { getCDNBundleSettings, getCDNProduct, getCDNProductAndSettings, getCDNProducts, getCDNProductsAndSettings, getCDNStoreSettings, getCDNWidgetSettings, resetCDNCache } from './api/cdn.js';
5
5
  export { applyDiscountToCharge, getCharge, listCharges, processCharge, removeDiscountsFromCharge, skipCharge, unskipCharge } from './api/charge.js';
6
+ export { getCollection, listCollectionProducts, listCollections } from './api/collection.js';
6
7
  export { getActiveChurnLandingPageURL, getCreditSummary, getCustomer, getCustomerPortalAccess, getDeliverySchedule, getGiftRedemptionLandingPageURL, sendCustomerNotification, updateCustomer } from './api/customer.js';
7
8
  export { getGiftPurchase, listGiftPurchases } from './api/gift.js';
8
9
  export { activateMembership, cancelMembership, changeMembership, getMembership, listMemberships } from './api/membership.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;"}
@@ -1,4 +1,5 @@
1
1
  import 'isomorphic-fetch';
2
+ import { nanoid } from 'nanoid/non-secure';
2
3
  import stringify from 'qs/lib/stringify';
3
4
  import { getOptions } from './options.js';
4
5
  import { RECHARGE_CDN_URL, RECHARGE_API_URL, SHOPIFY_APP_PROXY_URL } from '../constants/api.js';
@@ -11,6 +12,13 @@ function stringifyQuery(str) {
11
12
  arrayFormat: "comma"
12
13
  });
13
14
  }
15
+ function getInternalSession(session, fnName) {
16
+ return {
17
+ ...session,
18
+ internalFnCall: session.internalFnCall ?? fnName,
19
+ internalRequestId: session.internalRequestId ?? nanoid()
20
+ };
21
+ }
14
22
  async function cdnRequest(method, url, requestOptions = {}) {
15
23
  const opts = getOptions();
16
24
  return request(method, `${RECHARGE_CDN_URL(opts.environment)}/store/${opts.storeIdentifier}${url}`, requestOptions);
@@ -22,6 +30,8 @@ async function rechargeApiRequest(method, url, { id, query, data, headers } = {}
22
30
  const reqHeaders = {
23
31
  "X-Recharge-Access-Token": token,
24
32
  "X-Recharge-Version": "2021-11",
33
+ "X-Recharge-Fn": session.internalFnCall,
34
+ "X-Request-Id": session.internalRequestId,
25
35
  ...headers ? headers : {}
26
36
  };
27
37
  const localQuery = {
@@ -96,5 +106,5 @@ async function request(method, url, { id, query, data, headers } = {}) {
96
106
  return result;
97
107
  }
98
108
 
99
- export { cdnRequest, rechargeApiRequest, request, shopifyAppProxyRequest };
109
+ export { cdnRequest, getInternalSession, rechargeApiRequest, request, shopifyAppProxyRequest };
100
110
  //# sourceMappingURL=request.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"request.js","sources":["../../../src/utils/request.ts"],"sourcesContent":["import 'isomorphic-fetch';\n\nimport stringify from 'qs/lib/stringify';\n\nimport { Method, RequestHeaders, RequestOptions } from '../types';\nimport { getOptions } from './options';\nimport { RECHARGE_API_URL, RECHARGE_CDN_URL, SHOPIFY_APP_PROXY_URL } from '../constants/api';\nimport { Session } from '../types/session';\nimport { RechargeRequestError } from './error';\n\nfunction stringifyQuery(str: unknown): string {\n return stringify(str, {\n encode: false,\n indices: false,\n arrayFormat: 'comma',\n });\n}\n\nexport async function cdnRequest<T>(method: Method, url: string, requestOptions: RequestOptions = {}): Promise<T> {\n const opts = getOptions();\n return request(method, `${RECHARGE_CDN_URL(opts.environment)}/store/${opts.storeIdentifier}${url}`, requestOptions);\n}\n\nexport async function rechargeApiRequest<T>(\n method: Method,\n url: string,\n { id, query, data, headers }: RequestOptions = {},\n session: Session\n): Promise<T> {\n const { environment, environmentUri, storeIdentifier, loginRetryFn } = getOptions();\n const token = session.apiToken;\n const rechargeBaseUrl = RECHARGE_API_URL(environment, environmentUri);\n const reqHeaders: RequestHeaders = {\n 'X-Recharge-Access-Token': token,\n 'X-Recharge-Version': '2021-11',\n ...(headers ? headers : {}),\n };\n\n const localQuery = {\n shop_url: storeIdentifier,\n ...(query as any),\n };\n\n try {\n // await to catch any errors\n return await request<T>(method, `${rechargeBaseUrl}${url}`, { id, query: localQuery, data, headers: reqHeaders });\n } catch (error: unknown) {\n if (loginRetryFn && error instanceof RechargeRequestError && error.status === 401) {\n // call loginRetryFn and retry request on 401\n return loginRetryFn().then(session => {\n if (session) {\n return request(method, `${rechargeBaseUrl}${url}`, {\n id,\n query: localQuery,\n data,\n headers: {\n ...reqHeaders,\n 'X-Recharge-Access-Token': session.apiToken,\n },\n });\n }\n throw error;\n });\n }\n throw error;\n }\n}\n\nexport async function shopifyAppProxyRequest<T>(\n method: Method,\n url: string,\n requestOptions: RequestOptions = {}\n): Promise<T> {\n return request(method, `${SHOPIFY_APP_PROXY_URL}${url}`, requestOptions);\n}\n\nexport async function request<T>(\n method: Method,\n url: string,\n { id, query, data, headers }: RequestOptions = {}\n): Promise<T> {\n let reqUrl = url.trim();\n\n if (id) {\n reqUrl = [reqUrl, `${id}`.trim()].join('/');\n }\n\n if (query) {\n let exQuery;\n [reqUrl, exQuery] = reqUrl.split('?');\n const fullQuery = [exQuery, stringifyQuery(query)].join('&').replace(/^&/, '');\n reqUrl = `${reqUrl}${fullQuery ? `?${fullQuery}` : ''}`;\n }\n\n let reqBody;\n if (data && method !== 'get') {\n reqBody = JSON.stringify(data);\n }\n\n const reqHeaders: RequestHeaders = {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n 'X-Recharge-App': 'storefront-client',\n ...(headers ? headers : {}),\n };\n\n const response = await fetch(reqUrl, {\n method,\n headers: reqHeaders,\n body: reqBody,\n });\n\n let result;\n try {\n result = await response.json();\n } catch (e) {\n // If we get here, it means we were a no content response.\n }\n\n if (!response.ok) {\n if (result && result.error) {\n throw new RechargeRequestError(result.error, response.status);\n } else if (result && result.errors) {\n throw new RechargeRequestError(JSON.stringify(result.errors), response.status);\n } else {\n throw new RechargeRequestError('A connection error occurred while making the request');\n }\n }\n\n return result as T;\n}\n"],"names":["session"],"mappings":";;;;;;AAUA,SAAS,eAAe,GAAsB,EAAA;AAC5C,EAAA,OAAO,UAAU,GAAK,EAAA;AAAA,IACpB,MAAQ,EAAA,KAAA;AAAA,IACR,OAAS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AO,MAAM,CAAA,EAAG,SAAS,MAAM,CAAA,CAAA;AAAA,KACxE,MAAA;AACL,MAAM,MAAA,IAAI,qBAAqB,sDAAsD,CAAA,CAAA;AAAA,KACvF;AAAA,GACF;AAEA,EAAO,OAAA,MAAA,CAAA;AACT;;;;"}
1
+ {"version":3,"file":"request.js","sources":["../../../src/utils/request.ts"],"sourcesContent":["import 'isomorphic-fetch';\n\nimport { nanoid } from 'nanoid/non-secure';\nimport stringify from 'qs/lib/stringify';\n\nimport { Method, RequestHeaders, RequestOptions, InternalSession, Session } from '../types';\nimport { getOptions } from './options';\nimport { RECHARGE_API_URL, RECHARGE_CDN_URL, SHOPIFY_APP_PROXY_URL } from '../constants/api';\nimport { RechargeRequestError } from './error';\n\nfunction stringifyQuery(str: unknown): string {\n return stringify(str, {\n encode: false,\n indices: false,\n arrayFormat: 'comma',\n });\n}\n\n/** @internal */\nexport function getInternalSession(session: Session | InternalSession, fnName: string): InternalSession {\n return {\n ...session,\n internalFnCall: (session as InternalSession).internalFnCall ?? fnName,\n internalRequestId: (session as InternalSession).internalRequestId ?? nanoid(),\n };\n}\n\nexport async function cdnRequest<T>(method: Method, url: string, requestOptions: RequestOptions = {}): Promise<T> {\n const opts = getOptions();\n return request(method, `${RECHARGE_CDN_URL(opts.environment)}/store/${opts.storeIdentifier}${url}`, requestOptions);\n}\n\nexport async function rechargeApiRequest<T>(\n method: Method,\n url: string,\n { id, query, data, headers }: RequestOptions = {},\n session: InternalSession\n): Promise<T> {\n const { environment, environmentUri, storeIdentifier, loginRetryFn } = getOptions();\n const token = session.apiToken;\n const rechargeBaseUrl = RECHARGE_API_URL(environment, environmentUri);\n const reqHeaders: RequestHeaders = {\n 'X-Recharge-Access-Token': token,\n 'X-Recharge-Version': '2021-11',\n 'X-Recharge-Fn': session.internalFnCall,\n 'X-Request-Id': session.internalRequestId,\n ...(headers ? headers : {}),\n };\n\n const localQuery = {\n shop_url: storeIdentifier,\n ...(query as any),\n };\n\n try {\n // await to catch any errors\n return await request<T>(method, `${rechargeBaseUrl}${url}`, { id, query: localQuery, data, headers: reqHeaders });\n } catch (error: unknown) {\n if (loginRetryFn && error instanceof RechargeRequestError && error.status === 401) {\n // call loginRetryFn and retry request on 401\n return loginRetryFn().then(session => {\n if (session) {\n return request(method, `${rechargeBaseUrl}${url}`, {\n id,\n query: localQuery,\n data,\n headers: {\n ...reqHeaders,\n 'X-Recharge-Access-Token': session.apiToken,\n },\n });\n }\n throw error;\n });\n }\n throw error;\n }\n}\n\nexport async function shopifyAppProxyRequest<T>(\n method: Method,\n url: string,\n requestOptions: RequestOptions = {}\n): Promise<T> {\n return request(method, `${SHOPIFY_APP_PROXY_URL}${url}`, requestOptions);\n}\n\nexport async function request<T>(\n method: Method,\n url: string,\n { id, query, data, headers }: RequestOptions = {}\n): Promise<T> {\n let reqUrl = url.trim();\n\n if (id) {\n reqUrl = [reqUrl, `${id}`.trim()].join('/');\n }\n\n if (query) {\n let exQuery;\n [reqUrl, exQuery] = reqUrl.split('?');\n const fullQuery = [exQuery, stringifyQuery(query)].join('&').replace(/^&/, '');\n reqUrl = `${reqUrl}${fullQuery ? `?${fullQuery}` : ''}`;\n }\n\n let reqBody;\n if (data && method !== 'get') {\n reqBody = JSON.stringify(data);\n }\n\n const reqHeaders: RequestHeaders = {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n 'X-Recharge-App': 'storefront-client',\n ...(headers ? headers : {}),\n };\n\n const response = await fetch(reqUrl, {\n method,\n headers: reqHeaders,\n body: reqBody,\n });\n\n let result;\n try {\n result = await response.json();\n } catch (e) {\n // If we get here, it means we were a no content response.\n }\n\n if (!response.ok) {\n if (result && result.error) {\n throw new RechargeRequestError(result.error, response.status);\n } else if (result && result.errors) {\n throw new RechargeRequestError(JSON.stringify(result.errors), response.status);\n } else {\n throw new RechargeRequestError('A connection error occurred while making the request');\n }\n }\n\n return result as T;\n}\n"],"names":["session"],"mappings":";;;;;;;AAUA,SAAS,eAAe,GAAsB,EAAA;AAC5C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IAAA;AACF,IAAS,MAAA,GAAA,MAAM,SAAS,IAAK,EAAA,CAAA;AAAA,WACtB,CAAG,EAAA;AAAA,GAEZ;AAEA,EAAI,IAAA,CAAC,SAAS,EAAI,EAAA;AAChB,IAAI,IAAA,MAAA,IAAU,OAAO,KAAO,EAAA;AAC1B,MAAA,MAAM,IAAI,oBAAA,CAAqB,MAAO,CAAA,KAAA,EAAO,SAAS,MAAM,CAAA,CAAA;AAAA,KAC9D,MAAA,IAAW,MAAU,IAAA,MAAA,CAAO,MAAQ,EAAA;AAClC,MAAM,MAAA,IAAI,qBAAqB,IAAK,CAAA,SAAA,CAAU,OAAO,MAAM,CAAA,EAAG,SAAS,MAAM,CAAA,CAAA;AAAA,KACxE,MAAA;AACL,MAAM,MAAA,IAAI,qBAAqB,sDAAsD,CAAA,CAAA;AAAA,KACvF;AAAA,GACF;AAEA,EAAO,OAAA,MAAA,CAAA;AACT;;;;"}
package/dist/index.d.ts CHANGED
@@ -787,6 +787,8 @@ interface Customer {
787
787
  id: number;
788
788
  /** An object containing analytics data associated with the customer. */
789
789
  analytics_data: AnalyticsData;
790
+ /** A boolean that indicates whether Recharge credits will be applied to the next recurring charge */
791
+ apply_credit_to_next_recurring_charge: boolean;
790
792
  /** The date and time when the customer was created. */
791
793
  created_at: IsoDateString;
792
794
  /** The email address of the customer. */
@@ -805,10 +807,14 @@ interface Customer {
805
807
  hash: string;
806
808
  /** The customer’s last name. */
807
809
  last_name: string;
810
+ /** The customer's phone number */
811
+ phone: string;
808
812
  /** The number of active subscriptions on addresses associated with the customer. */
809
813
  subscriptions_active_count: number;
810
814
  /** The total number of subscriptions created on addresses associated with the customer. */
811
815
  subscriptions_total_count: number;
816
+ /** Whether the customer is tax exempt or not */
817
+ tax_exempt: boolean;
812
818
  /** The date and time when the customer was last updated. */
813
819
  updated_at: IsoDateString;
814
820
  /** Additional information as requested */
@@ -1407,37 +1413,23 @@ interface AddressListParams extends ListParams<AddressSortBy> {
1407
1413
  include?: AddressIncludes[];
1408
1414
  }
1409
1415
 
1410
- interface Session {
1411
- /** API token */
1412
- apiToken: string;
1413
- /** Customer ID attached to the session */
1414
- customerId?: string;
1415
- /** Message related to fetching the session */
1416
- message?: string;
1416
+ type Method = 'get' | 'post' | 'put' | 'delete';
1417
+ type Request = <T>(method: Method, url: string, options?: RequestOptions) => Promise<T>;
1418
+ interface GetRequestOptions {
1419
+ id?: string | number;
1420
+ query?: unknown;
1421
+ }
1422
+ interface CRUDRequestOptions {
1423
+ id?: string | number;
1424
+ data?: unknown;
1425
+ query?: unknown;
1426
+ }
1427
+ /** We only support headers with an object syntax */
1428
+ type RequestHeaders = Record<string, string>;
1429
+ interface RequestOptions extends GetRequestOptions, CRUDRequestOptions {
1430
+ fnName?: string;
1431
+ headers?: RequestHeaders;
1417
1432
  }
1418
-
1419
- /** Returns all addresses from the store, or addresses for the customer given in the parameter. */
1420
- declare function listAddresses(session: Session, query?: AddressListParams): Promise<AddressListResponse>;
1421
- /** Retrieves address for customer based on specified address id. */
1422
- declare function getAddress(session: Session, id: string | number, options?: GetAddressOptions): Promise<Address>;
1423
- /** Create a new address for a customer. */
1424
- declare function createAddress(session: Session, createRequest: CreateAddressRequest): Promise<Address>;
1425
- /** Updates an existing address to match the specified parameters. */
1426
- declare function updateAddress(session: Session, id: string | number, updateRequest: UpdateAddressRequest): Promise<Address>;
1427
- /** Apply discount code to an address. Addresses are currently limited to a single discount. */
1428
- declare function applyDiscountToAddress(session: Session, id: string | number, discountCode: string): Promise<Address>;
1429
- /** Removes all discounts from an address. */
1430
- declare function removeDiscountsFromAddress(session: Session, id: string | number): Promise<Address>;
1431
- /** Deletes an address. Only Addresses with no active Subscriptions can be deleted. */
1432
- declare function deleteAddress(session: Session, id: string | number): Promise<void>;
1433
- /**
1434
- * Merges up to 10 source addresses into 1 target address.
1435
- */
1436
- declare function mergeAddresses(session: Session, mergeRequest: MergeAddressesRequest): Promise<Address>;
1437
- /**
1438
- * Skip a Charge in the future for one or multiple Subscriptions associated with the Address.
1439
- */
1440
- declare function skipFutureCharge(session: Session, id: string | number, skipRequest: SkipFutureChargeAddressRequest): Promise<Charge>;
1441
1433
 
1442
1434
  interface LoginResponse {
1443
1435
  api_token: string;
@@ -1458,34 +1450,6 @@ interface PasswordlessValidateResponse {
1458
1450
  errors?: string;
1459
1451
  }
1460
1452
 
1461
- declare function loginShopifyAppProxy(): Promise<Session>;
1462
- /** @deprecated Use `loginWithShopifyStorefront` instead */
1463
- declare function loginShopifyApi(shopifyStorefrontToken: string, shopifyCustomerAccessToken?: string): Promise<Session | null>;
1464
- declare function loginWithShopifyStorefront(shopifyStorefrontToken: string, shopifyCustomerAccessToken?: string): Promise<Session | null>;
1465
- declare function loginWithShopifyCustomerAccount(shopifyCustomerAccessToken?: string): Promise<Session | null>;
1466
- declare function sendPasswordlessCode(email: string, options?: PasswordlessOptions): Promise<string>;
1467
- declare function sendPasswordlessCodeAppProxy(email: string, options?: PasswordlessOptions): Promise<string>;
1468
- declare function validatePasswordlessCode(email: string, session_token: string, code: string): Promise<Session>;
1469
- declare function validatePasswordlessCodeAppProxy(email: string, session_token: string, code: string): Promise<Session>;
1470
- declare function loginCustomerPortal(): Promise<Session>;
1471
-
1472
- type Method = 'get' | 'post' | 'put' | 'delete';
1473
- type Request = <T>(method: Method, url: string, options?: RequestOptions) => Promise<T>;
1474
- interface GetRequestOptions {
1475
- id?: string | number;
1476
- query?: unknown;
1477
- }
1478
- interface CRUDRequestOptions {
1479
- id?: string | number;
1480
- data?: unknown;
1481
- query?: unknown;
1482
- }
1483
- /** We only support headers with an object syntax */
1484
- type RequestHeaders = Record<string, string>;
1485
- interface RequestOptions extends GetRequestOptions, CRUDRequestOptions {
1486
- headers?: RequestHeaders;
1487
- }
1488
-
1489
1453
  type ProductInclude = 'collections';
1490
1454
  type ProductSource = 'all' | 'in_recharge' | 'not_in_recharge';
1491
1455
  type PublishStatus = 'published' | 'unpublished' | 'any';
@@ -2096,6 +2060,37 @@ interface CDNBundleSettings extends Omit<BundleProduct, 'created_at' | 'custom_p
2096
2060
  variants: CDNBundleVariant[];
2097
2061
  }
2098
2062
 
2063
+ type CollectionsSortBy = 'id-desc' | 'id-asc' | 'created_at-asc' | 'created_at-desc' | 'title-asc' | 'title-desc';
2064
+ type CollectionTypes = 'automatic' | 'manual';
2065
+ interface Collection {
2066
+ /** Unique numeric identifier for the Collection. */
2067
+ id: number;
2068
+ /** The title of the Collection. A short descriptive definition of the Collection. */
2069
+ title: string;
2070
+ /** The Collection description. Used to store a detailed explanation of the Collection content and its purpose. */
2071
+ description: string;
2072
+ sort_order: CollectionsSortBy | 'manual';
2073
+ /** The type of the Collection. manual stands for Collections which were manually created ie. when the products where explicitly selected to be part of the Collection. */
2074
+ type: CollectionTypes;
2075
+ /** Sort order of products within the collection */
2076
+ manual_sort_order: string[];
2077
+ /** The date and time when the Collection was created. */
2078
+ created_at: IsoDateString;
2079
+ /** The date and time when the Collection was last updated. */
2080
+ updated_at: IsoDateString;
2081
+ }
2082
+ interface CollectionsResponse {
2083
+ next_cursor: null | string;
2084
+ previous_cursor: null | string;
2085
+ collections: Collection[];
2086
+ }
2087
+ interface CollectionListParams extends ListParams<CollectionsSortBy> {
2088
+ /** Filter by collection type. */
2089
+ type?: CollectionTypes;
2090
+ /** Filter by title. */
2091
+ title?: string;
2092
+ }
2093
+
2099
2094
  /** A gift given to a customer. */
2100
2095
  interface GiftPurchase {
2101
2096
  /** Unique numeric identifier for the Gift. */
@@ -2254,21 +2249,6 @@ interface MembershipBenefit {
2254
2249
  updated_at: IsoDateString;
2255
2250
  }
2256
2251
 
2257
- /** @internal */
2258
- type CollectionsSortBy = 'id-desc' | 'id-asc' | 'created_at-asc' | 'created_at-desc' | 'updated_at-desc' | 'updated_at-asc' | 'title-asc' | 'title-desc';
2259
- /** @internal */
2260
- type CollectionTypes = 'automatic' | 'manual';
2261
- /** @internal */
2262
- interface Collection {
2263
- id: number;
2264
- title: string;
2265
- description: string;
2266
- sort_order: CollectionsSortBy;
2267
- type: CollectionTypes;
2268
- created_at: IsoDateString;
2269
- updated_at: IsoDateString;
2270
- }
2271
-
2272
2252
  /** @internal */
2273
2253
  interface ExternalAttributeSchema {
2274
2254
  order_tag: string;
@@ -2406,6 +2386,20 @@ interface OnetimeListParams extends ListParams<OnetimesSortBy> {
2406
2386
  updated_at_min?: IsoDateString;
2407
2387
  }
2408
2388
 
2389
+ interface Session {
2390
+ /** API token */
2391
+ apiToken: string;
2392
+ /** Customer ID attached to the session */
2393
+ customerId?: string;
2394
+ /** Message related to fetching the session */
2395
+ message?: string;
2396
+ }
2397
+ /** @internal */
2398
+ interface InternalSession extends Session {
2399
+ internalFnCall: string;
2400
+ internalRequestId: string;
2401
+ }
2402
+
2409
2403
  /** @internal */
2410
2404
  type StorefrontEnvironment = 'stage' | 'prod' | 'prestage' | 'preprod';
2411
2405
  /** @internal */
@@ -2481,6 +2475,40 @@ interface ShippingCountry {
2481
2475
  provinces: ShippingProvince[];
2482
2476
  }
2483
2477
 
2478
+ /** Returns all addresses from the store, or addresses for the customer given in the parameter. */
2479
+ declare function listAddresses(session: Session, query?: AddressListParams): Promise<AddressListResponse>;
2480
+ /** Retrieves address for customer based on specified address id. */
2481
+ declare function getAddress(session: Session, id: string | number, options?: GetAddressOptions): Promise<Address>;
2482
+ /** Create a new address for a customer. */
2483
+ declare function createAddress(session: Session, createRequest: CreateAddressRequest): Promise<Address>;
2484
+ /** Updates an existing address to match the specified parameters. */
2485
+ declare function updateAddress(session: Session, id: string | number, updateRequest: UpdateAddressRequest): Promise<Address>;
2486
+ /** Apply discount code to an address. Addresses are currently limited to a single discount. */
2487
+ declare function applyDiscountToAddress(session: Session, id: string | number, discountCode: string): Promise<Address>;
2488
+ /** Removes all discounts from an address. */
2489
+ declare function removeDiscountsFromAddress(session: Session, id: string | number): Promise<Address>;
2490
+ /** Deletes an address. Only Addresses with no active Subscriptions can be deleted. */
2491
+ declare function deleteAddress(session: Session, id: string | number): Promise<void>;
2492
+ /**
2493
+ * Merges up to 10 source addresses into 1 target address.
2494
+ */
2495
+ declare function mergeAddresses(session: Session, mergeRequest: MergeAddressesRequest): Promise<Address>;
2496
+ /**
2497
+ * Skip a Charge in the future for one or multiple Subscriptions associated with the Address.
2498
+ */
2499
+ declare function skipFutureCharge(session: Session, id: string | number, skipRequest: SkipFutureChargeAddressRequest): Promise<Charge>;
2500
+
2501
+ declare function loginShopifyAppProxy(): Promise<Session>;
2502
+ /** @deprecated Use `loginWithShopifyStorefront` instead */
2503
+ declare function loginShopifyApi(shopifyStorefrontToken: string, shopifyCustomerAccessToken?: string): Promise<Session | null>;
2504
+ declare function loginWithShopifyStorefront(shopifyStorefrontToken: string, shopifyCustomerAccessToken?: string): Promise<Session | null>;
2505
+ declare function loginWithShopifyCustomerAccount(shopifyCustomerAccessToken?: string): Promise<Session | null>;
2506
+ declare function sendPasswordlessCode(email: string, options?: PasswordlessOptions): Promise<string>;
2507
+ declare function sendPasswordlessCodeAppProxy(email: string, options?: PasswordlessOptions): Promise<string>;
2508
+ declare function validatePasswordlessCode(email: string, session_token: string, code: string): Promise<Session>;
2509
+ declare function validatePasswordlessCodeAppProxy(email: string, session_token: string, code: string): Promise<Session>;
2510
+ declare function loginCustomerPortal(): Promise<Session>;
2511
+
2484
2512
  declare function getBundleId(bundle: BundleAppProxy): Promise<string>;
2485
2513
  declare function getDynamicBundleItems(bundle: BundleAppProxy, shopifyProductHandle: string): DynamicBundleItemAppProxy[];
2486
2514
  declare function validateBundle(bundle: BundleAppProxy): Promise<true | string>;
@@ -2527,6 +2555,15 @@ declare function skipCharge(session: Session, id: number | string, purchaseItemI
2527
2555
  declare function unskipCharge(session: Session, id: number | string, purchaseItemIds: (string | number)[], query?: SkipChargeParams): Promise<Charge>;
2528
2556
  declare function processCharge(session: Session, id: number | string): Promise<Charge>;
2529
2557
 
2558
+ type ProductListResponse<T extends ProductSearchParams_2020_12 | ProductSearchParams_2022_06> = T extends ProductSearchParams_2020_12 ? {
2559
+ products: Product_2020_12[];
2560
+ } : {
2561
+ products: Product_2022_06[];
2562
+ };
2563
+ declare function getCollection(session: Session, id: string | number): Promise<Collection>;
2564
+ declare function listCollections(session: Session, query?: CollectionListParams): Promise<CollectionsResponse>;
2565
+ declare function listCollectionProducts<T extends ProductSearchParams_2020_12 | ProductSearchParams_2022_06>(session: Session, id: string | number, query: T): Promise<ProductListResponse<T>>;
2566
+
2530
2567
  declare function getCustomer(session: Session, options?: GetCustomerOptions): Promise<Customer>;
2531
2568
  declare function updateCustomer(session: Session, updateRequest: UpdateCustomerRequest): Promise<Customer>;
2532
2569
  declare function getDeliverySchedule(session: Session, query?: CustomerDeliveryScheduleParams): Promise<Delivery[]>;
@@ -2659,4 +2696,4 @@ declare const api: {
2659
2696
  };
2660
2697
  declare function initRecharge(opt?: InitOptions): void;
2661
2698
 
2662
- export { type ActivateMembershipRequest, type AddToCartCallbackSettings, type AddonSettings, type Address, type AddressIncludes, type AddressListParams, type AddressListResponse, type AddressResponse, type AddressSortBy, type AnalyticsData, type AssociatedAddress, type BasicSubscriptionParams, type BooleanLike, type BooleanNumbers, type BooleanString, type BooleanStringNumbers, type BundleAppProxy, type BundlePriceRule, type BundleProduct, type BundleProductLayoutSettings, type BundlePurchaseItem, type BundlePurchaseItemParams, type BundleSelection, type BundleSelectionAppProxy, type BundleSelectionItem, type BundleSelectionItemRequiredCreateProps, type BundleSelectionListParams, type BundleSelectionsResponse, type BundleSelectionsSortBy, type BundleTemplateSettings, type BundleTemplateType, type BundleTranslations, type BundleVariant, type BundleVariantOptionSource, type BundleVariantRange, type BundleVariantSelectionDefault, type CDNBaseWidgetSettings, type CDNBundleSettings, type CDNBundleVariant, type CDNBundleVariantOptionSource, type CDNPlan, type CDNProduct, type CDNProductAndSettings, type CDNProductKeyObject, type CDNProductQuery_2020_12, type CDNProductQuery_2022_06, type CDNProductRaw, type CDNProductResource, type CDNProductResponseType, type CDNProductType, type CDNProductVariant_2022_06, type CDNProduct_2022_06, type CDNProductsAndSettings, type CDNProductsAndSettingsResource, type CDNStoreSettings, type CDNSubscriptionOption, type CDNVariant, type CDNVersion, type CDNWidgetSettings, type CDNWidgetSettingsRaw, type CDNWidgetSettingsResource, type CRUDRequestOptions, type CancelMembershipRequest, type CancelSubscriptionRequest, type ChangeMembershipRequest, type ChannelSettings, type Charge, type ChargeIncludes, type ChargeListParams, type ChargeListResponse, type ChargeResponse, type ChargeSortBy, type ChargeStatus, type ColorString, type CreateAddressRequest, type CreateBundleSelectionRequest, type CreateMetafieldRequest, type CreateOnetimeRequest, type CreatePaymentMethodRequest, type CreateRecipientAddress, type CreateSubscriptionRequest, type CreditAccount, type CreditAccountType, type CreditSummaryIncludes, type CrossSellsSettings, type Customer, type CustomerCreditSummary, type CustomerDeliveryScheduleParams, type CustomerDeliveryScheduleResponse, type CustomerIncludes, type CustomerNotification, type CustomerNotificationOptions, type CustomerNotificationTemplate, type CustomerNotificationType, type CustomerPortalAccessResponse, type Delivery, type DeliveryLineItem, type DeliveryOrder, type DeliveryPaymentMethod, type Discount, type DiscountType, type DynamicBundleItemAppProxy, type DynamicBundlePropertiesAppProxy, type ExternalAttributeSchema, type ExternalId, type ExternalTransactionId, type FirstOption, type GetAddressOptions, type GetChargeOptions, type GetCreditSummaryOptions, type GetCustomerOptions, type GetMembershipProgramOptions, type GetPaymentMethodOptions, type GetRequestOptions, type GetSubscriptionOptions, type GiftPurchase, type GiftPurchasesParams, type GiftPurchasesResponse, type HTMLString, type InitOptions, type IntervalUnit, type IsoDateString, type LineItem, type ListParams, type LoginResponse, type Membership, type MembershipBenefit, type MembershipIncludes, type MembershipListParams, type MembershipListResponse, type MembershipProgram, type MembershipProgramIncludes, type MembershipProgramListParams, type MembershipProgramListResponse, type MembershipProgramResponse, type MembershipProgramSortBy, type MembershipProgramStatus, type MembershipResponse, type MembershipStatus, type MembershipsSortBy, type MergeAddressesRequest, type Metafield, type MetafieldOptionalCreateProps, type MetafieldOwnerResource, type MetafieldRequiredCreateProps, type Method, type Modifier, type MultiStepSettings, type OnePageSettings, type Onetime, type OnetimeListParams, type OnetimeOptionalCreateProps, type OnetimeRequiredCreateProps, type OnetimesResponse, type OnetimesSortBy, type Order, type OrderIncludes, type OrderListParams, type OrderSortBy, type OrderStatus, type OrderType, type OrdersResponse, type PasswordlessCodeResponse, type PasswordlessOptions, type PasswordlessValidateResponse, type PaymentDetails, type PaymentMethod, type PaymentMethodIncludes, type PaymentMethodListParams, type PaymentMethodOptionalCreateProps, type PaymentMethodRequiredCreateProps, type PaymentMethodSortBy, type PaymentMethodStatus, type PaymentMethodsResponse, type PaymentType, type Plan, type PlanListParams, type PlanSortBy, type PlanType, type PlansResponse, type ProcessorName, type ProductImage, type ProductInclude, type ProductOption, type ProductSearchParams_2020_12, type ProductSearchParams_2022_06, type ProductSearchResponse_2020_12, type ProductSearchResponse_2022_06, type ProductSearchType, type ProductSource, type ProductValueOption, type ProductVariant_2020_12, type ProductVariant_2022_06, type Product_2020_12, type Product_2022_06, type Property, type PublishStatus, type Request, type RequestHeaders, type RequestOptions, type SellingPlan, type SellingPlanGroup, type Session, type ShippingCountriesOptions, type ShippingCountriesResponse, type ShippingCountry, type ShippingLine, type ShippingProvince, type ShopifyUpdatePaymentInfoOptions, type SkipChargeParams, type SkipFutureChargeAddressRequest, type SkipFutureChargeAddressResponse, type SortBy, type SortField, type SortKeys, type StepSettings, type StepSettingsCommon, type StepSettingsTypes, type StorefrontEnvironment, type StorefrontOptions, type StorefrontPurchaseOption, type SubType, type Subscription, type SubscriptionIncludes, type SubscriptionListParams, type SubscriptionOption, type SubscriptionOptionalCreateProps, type SubscriptionPreferences, type SubscriptionRequiredCreateProps, type SubscriptionSortBy, type SubscriptionStatus, type Subscription_2021_01, type SubscriptionsResponse, type TaxLine, type Translations, type UpdateAddressRequest, type UpdateBundlePurchaseItem, type UpdateBundleSelectionRequest, type UpdateCustomerRequest, type UpdateMetafieldRequest, type UpdateOnetimeRequest, type UpdatePaymentMethodRequest, type UpdateSubscriptionParams, type UpdateSubscriptionRequest, type UpdateSubscriptionsParams, type UpdateSubscriptionsRequest, type VariantSelector, type VariantSelectorStepSetting, type WidgetIconColor, type WidgetTemplateType, type WidgetVisibility, activateMembership, activateSubscription, api, applyDiscountToAddress, applyDiscountToCharge, cancelMembership, cancelSubscription, changeMembership, createAddress, createBundleSelection, createMetafield, createOnetime, createPaymentMethod, createSubscription, createSubscriptions, deleteAddress, deleteBundleSelection, deleteMetafield, deleteOnetime, getActiveChurnLandingPageURL, getAddress, getBundleId, getBundleSelection, getCDNBundleSettings, getCDNProduct, getCDNProductAndSettings, getCDNProducts, getCDNProductsAndSettings, getCDNStoreSettings, getCDNWidgetSettings, getCharge, getCreditSummary, getCustomer, getCustomerPortalAccess, getDeliverySchedule, getDynamicBundleItems, getGiftPurchase, getGiftRedemptionLandingPageURL, getMembership, getMembershipProgram, getOnetime, getOrder, getPaymentMethod, getPlan, getShippingCountries, getSubscription, initRecharge, type intervalUnit, listAddresses, listBundleSelections, listCharges, listGiftPurchases, listMembershipPrograms, listMemberships, listOnetimes, listOrders, listPaymentMethods, listPlans, listSubscriptions, loginCustomerPortal, loginShopifyApi, loginShopifyAppProxy, loginWithShopifyCustomerAccount, loginWithShopifyStorefront, type membershipIncludes, mergeAddresses, processCharge, productSearch, removeDiscountsFromAddress, removeDiscountsFromCharge, resetCDNCache, sendCustomerNotification, sendPasswordlessCode, sendPasswordlessCodeAppProxy, skipCharge, skipFutureCharge, skipGiftSubscriptionCharge, skipSubscriptionCharge, unskipCharge, updateAddress, updateBundle, updateBundleSelection, updateCustomer, updateMetafield, updateOnetime, updatePaymentMethod, updateSubscription, updateSubscriptionAddress, updateSubscriptionChargeDate, updateSubscriptions, validateBundle, validateDynamicBundle, validatePasswordlessCode, validatePasswordlessCodeAppProxy };
2699
+ export { type ActivateMembershipRequest, type AddToCartCallbackSettings, type AddonSettings, type Address, type AddressIncludes, type AddressListParams, type AddressListResponse, type AddressResponse, type AddressSortBy, type AnalyticsData, type AssociatedAddress, type BasicSubscriptionParams, type BooleanLike, type BooleanNumbers, type BooleanString, type BooleanStringNumbers, type BundleAppProxy, type BundlePriceRule, type BundleProduct, type BundleProductLayoutSettings, type BundlePurchaseItem, type BundlePurchaseItemParams, type BundleSelection, type BundleSelectionAppProxy, type BundleSelectionItem, type BundleSelectionItemRequiredCreateProps, type BundleSelectionListParams, type BundleSelectionsResponse, type BundleSelectionsSortBy, type BundleTemplateSettings, type BundleTemplateType, type BundleTranslations, type BundleVariant, type BundleVariantOptionSource, type BundleVariantRange, type BundleVariantSelectionDefault, type CDNBaseWidgetSettings, type CDNBundleSettings, type CDNBundleVariant, type CDNBundleVariantOptionSource, type CDNPlan, type CDNProduct, type CDNProductAndSettings, type CDNProductKeyObject, type CDNProductQuery_2020_12, type CDNProductQuery_2022_06, type CDNProductRaw, type CDNProductResource, type CDNProductResponseType, type CDNProductType, type CDNProductVariant_2022_06, type CDNProduct_2022_06, type CDNProductsAndSettings, type CDNProductsAndSettingsResource, type CDNStoreSettings, type CDNSubscriptionOption, type CDNVariant, type CDNVersion, type CDNWidgetSettings, type CDNWidgetSettingsRaw, type CDNWidgetSettingsResource, type CRUDRequestOptions, type CancelMembershipRequest, type CancelSubscriptionRequest, type ChangeMembershipRequest, type ChannelSettings, type Charge, type ChargeIncludes, type ChargeListParams, type ChargeListResponse, type ChargeResponse, type ChargeSortBy, type ChargeStatus, type Collection, type CollectionListParams, type CollectionTypes, type CollectionsResponse, type CollectionsSortBy, type ColorString, type CreateAddressRequest, type CreateBundleSelectionRequest, type CreateMetafieldRequest, type CreateOnetimeRequest, type CreatePaymentMethodRequest, type CreateRecipientAddress, type CreateSubscriptionRequest, type CreditAccount, type CreditAccountType, type CreditSummaryIncludes, type CrossSellsSettings, type Customer, type CustomerCreditSummary, type CustomerDeliveryScheduleParams, type CustomerDeliveryScheduleResponse, type CustomerIncludes, type CustomerNotification, type CustomerNotificationOptions, type CustomerNotificationTemplate, type CustomerNotificationType, type CustomerPortalAccessResponse, type Delivery, type DeliveryLineItem, type DeliveryOrder, type DeliveryPaymentMethod, type Discount, type DiscountType, type DynamicBundleItemAppProxy, type DynamicBundlePropertiesAppProxy, type ExternalAttributeSchema, type ExternalId, type ExternalTransactionId, type FirstOption, type GetAddressOptions, type GetChargeOptions, type GetCreditSummaryOptions, type GetCustomerOptions, type GetMembershipProgramOptions, type GetPaymentMethodOptions, type GetRequestOptions, type GetSubscriptionOptions, type GiftPurchase, type GiftPurchasesParams, type GiftPurchasesResponse, type HTMLString, type InitOptions, type InternalSession, type IntervalUnit, type IsoDateString, type LineItem, type ListParams, type LoginResponse, type Membership, type MembershipBenefit, type MembershipIncludes, type MembershipListParams, type MembershipListResponse, type MembershipProgram, type MembershipProgramIncludes, type MembershipProgramListParams, type MembershipProgramListResponse, type MembershipProgramResponse, type MembershipProgramSortBy, type MembershipProgramStatus, type MembershipResponse, type MembershipStatus, type MembershipsSortBy, type MergeAddressesRequest, type Metafield, type MetafieldOptionalCreateProps, type MetafieldOwnerResource, type MetafieldRequiredCreateProps, type Method, type Modifier, type MultiStepSettings, type OnePageSettings, type Onetime, type OnetimeListParams, type OnetimeOptionalCreateProps, type OnetimeRequiredCreateProps, type OnetimesResponse, type OnetimesSortBy, type Order, type OrderIncludes, type OrderListParams, type OrderSortBy, type OrderStatus, type OrderType, type OrdersResponse, type PasswordlessCodeResponse, type PasswordlessOptions, type PasswordlessValidateResponse, type PaymentDetails, type PaymentMethod, type PaymentMethodIncludes, type PaymentMethodListParams, type PaymentMethodOptionalCreateProps, type PaymentMethodRequiredCreateProps, type PaymentMethodSortBy, type PaymentMethodStatus, type PaymentMethodsResponse, type PaymentType, type Plan, type PlanListParams, type PlanSortBy, type PlanType, type PlansResponse, type ProcessorName, type ProductImage, type ProductInclude, type ProductListResponse, type ProductOption, type ProductSearchParams_2020_12, type ProductSearchParams_2022_06, type ProductSearchResponse_2020_12, type ProductSearchResponse_2022_06, type ProductSearchType, type ProductSource, type ProductValueOption, type ProductVariant_2020_12, type ProductVariant_2022_06, type Product_2020_12, type Product_2022_06, type Property, type PublishStatus, type Request, type RequestHeaders, type RequestOptions, type SellingPlan, type SellingPlanGroup, type Session, type ShippingCountriesOptions, type ShippingCountriesResponse, type ShippingCountry, type ShippingLine, type ShippingProvince, type ShopifyUpdatePaymentInfoOptions, type SkipChargeParams, type SkipFutureChargeAddressRequest, type SkipFutureChargeAddressResponse, type SortBy, type SortField, type SortKeys, type StepSettings, type StepSettingsCommon, type StepSettingsTypes, type StorefrontEnvironment, type StorefrontOptions, type StorefrontPurchaseOption, type SubType, type Subscription, type SubscriptionIncludes, type SubscriptionListParams, type SubscriptionOption, type SubscriptionOptionalCreateProps, type SubscriptionPreferences, type SubscriptionRequiredCreateProps, type SubscriptionSortBy, type SubscriptionStatus, type Subscription_2021_01, type SubscriptionsResponse, type TaxLine, type Translations, type UpdateAddressRequest, type UpdateBundlePurchaseItem, type UpdateBundleSelectionRequest, type UpdateCustomerRequest, type UpdateMetafieldRequest, type UpdateOnetimeRequest, type UpdatePaymentMethodRequest, type UpdateSubscriptionParams, type UpdateSubscriptionRequest, type UpdateSubscriptionsParams, type UpdateSubscriptionsRequest, type VariantSelector, type VariantSelectorStepSetting, type WidgetIconColor, type WidgetTemplateType, type WidgetVisibility, activateMembership, activateSubscription, api, applyDiscountToAddress, applyDiscountToCharge, cancelMembership, cancelSubscription, changeMembership, createAddress, createBundleSelection, createMetafield, createOnetime, createPaymentMethod, createSubscription, createSubscriptions, deleteAddress, deleteBundleSelection, deleteMetafield, deleteOnetime, getActiveChurnLandingPageURL, getAddress, getBundleId, getBundleSelection, getCDNBundleSettings, getCDNProduct, getCDNProductAndSettings, getCDNProducts, getCDNProductsAndSettings, getCDNStoreSettings, getCDNWidgetSettings, getCharge, getCollection, getCreditSummary, getCustomer, getCustomerPortalAccess, getDeliverySchedule, getDynamicBundleItems, getGiftPurchase, getGiftRedemptionLandingPageURL, getMembership, getMembershipProgram, getOnetime, getOrder, getPaymentMethod, getPlan, getShippingCountries, getSubscription, initRecharge, type intervalUnit, listAddresses, listBundleSelections, listCharges, listCollectionProducts, listCollections, listGiftPurchases, listMembershipPrograms, listMemberships, listOnetimes, listOrders, listPaymentMethods, listPlans, listSubscriptions, loginCustomerPortal, loginShopifyApi, loginShopifyAppProxy, loginWithShopifyCustomerAccount, loginWithShopifyStorefront, type membershipIncludes, mergeAddresses, processCharge, productSearch, removeDiscountsFromAddress, removeDiscountsFromCharge, resetCDNCache, sendCustomerNotification, sendPasswordlessCode, sendPasswordlessCodeAppProxy, skipCharge, skipFutureCharge, skipGiftSubscriptionCharge, skipSubscriptionCharge, unskipCharge, updateAddress, updateBundle, updateBundleSelection, updateCustomer, updateMetafield, updateOnetime, updatePaymentMethod, updateSubscription, updateSubscriptionAddress, updateSubscriptionChargeDate, updateSubscriptions, validateBundle, validateDynamicBundle, validatePasswordlessCode, validatePasswordlessCodeAppProxy };