@rechargeapps/storefront-client 1.24.0 → 1.25.0
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.
- package/dist/cjs/api/auth.js +1 -1
- package/dist/cjs/api/subscription.js +28 -0
- package/dist/cjs/api/subscription.js.map +1 -1
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/utils/request.js +1 -1
- package/dist/esm/api/auth.js +1 -1
- package/dist/esm/api/subscription.js +28 -1
- package/dist/esm/api/subscription.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/utils/request.js +1 -1
- package/dist/index.d.ts +27 -9
- package/dist/umd/recharge-client.min.js +7 -7
- package/package.json +1 -1
package/dist/cjs/api/auth.js
CHANGED
|
@@ -142,7 +142,7 @@ async function rechargeAdminRequest(method, url, { id, query, data, headers } =
|
|
|
142
142
|
...storefrontAccessToken ? { "X-Recharge-Storefront-Access-Token": storefrontAccessToken } : {},
|
|
143
143
|
...appName ? { "X-Recharge-Sdk-App-Name": appName } : {},
|
|
144
144
|
...appVersion ? { "X-Recharge-Sdk-App-Version": appVersion } : {},
|
|
145
|
-
"X-Recharge-Sdk-Version": "1.
|
|
145
|
+
"X-Recharge-Sdk-Version": "1.25.0",
|
|
146
146
|
...headers ? headers : {}
|
|
147
147
|
};
|
|
148
148
|
return request.request(method, `${rechargeBaseUrl}${url}`, { id, query, data, headers: reqHeaders });
|
|
@@ -179,11 +179,39 @@ async function updateSubscriptions(session, addressId, updateRequestBulk, query)
|
|
|
179
179
|
);
|
|
180
180
|
return subscriptions.map(subscription.subscriptionMapperOldToNew);
|
|
181
181
|
}
|
|
182
|
+
async function deleteSubscriptions(session, addressId, deleteRequestBulk, query) {
|
|
183
|
+
const length = deleteRequestBulk.length;
|
|
184
|
+
if (length < 1 || length > 21) {
|
|
185
|
+
throw new Error("Number of subscriptions must be between 1 and 20.");
|
|
186
|
+
}
|
|
187
|
+
const { customerId } = session;
|
|
188
|
+
if (!customerId) {
|
|
189
|
+
throw new Error("No customerId in session.");
|
|
190
|
+
}
|
|
191
|
+
let localQuery = void 0;
|
|
192
|
+
if (query?.allow_onetimes !== void 0) {
|
|
193
|
+
localQuery = { allow_onetimes: query.allow_onetimes };
|
|
194
|
+
}
|
|
195
|
+
await request.rechargeApiRequest(
|
|
196
|
+
"delete",
|
|
197
|
+
`/addresses/${addressId}/subscriptions-bulk`,
|
|
198
|
+
{
|
|
199
|
+
data: { subscriptions: deleteRequestBulk, send_email: query?.send_email ?? false },
|
|
200
|
+
headers: {
|
|
201
|
+
"X-Recharge-Version": "2021-01"
|
|
202
|
+
},
|
|
203
|
+
query: localQuery
|
|
204
|
+
},
|
|
205
|
+
request.getInternalSession(session, "deleteSubscriptions")
|
|
206
|
+
);
|
|
207
|
+
return void 0;
|
|
208
|
+
}
|
|
182
209
|
|
|
183
210
|
exports.activateSubscription = activateSubscription;
|
|
184
211
|
exports.cancelSubscription = cancelSubscription;
|
|
185
212
|
exports.createSubscription = createSubscription;
|
|
186
213
|
exports.createSubscriptions = createSubscriptions;
|
|
214
|
+
exports.deleteSubscriptions = deleteSubscriptions;
|
|
187
215
|
exports.getSubscription = getSubscription;
|
|
188
216
|
exports.listSubscriptions = listSubscriptions;
|
|
189
217
|
exports.skipGiftSubscriptionCharge = skipGiftSubscriptionCharge;
|
|
@@ -1 +1 @@
|
|
|
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 CreateSubscriptionsParams,\n CreateSubscriptionsRequest,\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: CreateSubscriptionsRequest[],\n query?: CreateSubscriptionsParams\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 query,\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 // setup query params\n let localQuery: { allow_onetimes?: boolean } | undefined = undefined;\n if (query?.allow_onetimes !== undefined) {\n localQuery = { allow_onetimes: query.allow_onetimes };\n }\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 query: localQuery,\n },\n getInternalSession(session, 'updateSubscriptions')\n );\n return subscriptions.map(subscriptionMapperOldToNew);\n}\n"],"names":["rechargeApiRequest","getInternalSession","bulkSubscriptionCreateMapper","subscriptionMapperOldToNew","bulkSubscriptionUpdateMapper"],"mappings":";;;;;;AA6BsB,eAAA,eAAA,CACpB,OACA,EAAA,EAAA,EACA,OACuB,EAAA;AACvB,EAAM,MAAA,EAAE,YAAa,EAAA,GAAI,MAAMA,0BAAA;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,IACAC,0BAAA,CAAmB,SAAS,iBAAiB,CAAA;AAAA,GAC/C,CAAA;AACA,EAAO,OAAA,YAAA,CAAA;AACT,CAAA;AAEgB,SAAA,iBAAA,CAAkB,SAAk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AAA,CAAA;AAC3D,EAAI,IAAA,KAAA,EAAO,mBAAmB,KAAW,CAAA,EAAA;AACvC,IAAa,UAAA,GAAA,EAAE,cAAgB,EAAA,KAAA,CAAM,cAAe,EAAA,CAAA;AAAA,GACtD;AACA,EAAM,MAAA,EAAE,aAAc,EAAA,GAAI,MAAMJ,0BAAA;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,MACA,KAAO,EAAA,UAAA;AAAA,KACT;AAAA,IACAC,0BAAA,CAAmB,SAAS,qBAAqB,CAAA;AAAA,GACnD,CAAA;AACA,EAAO,OAAA,aAAA,CAAc,IAAIE,uCAA0B,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 CreateSubscriptionsParams,\n CreateSubscriptionsRequest,\n DeleteSubscriptionsParams,\n DeleteSubscriptionsRequest,\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: CreateSubscriptionsRequest[],\n query?: CreateSubscriptionsParams\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 query,\n },\n getInternalSession(session, 'createSubscriptions')\n );\n return subscriptions.map(subscriptionMapperOldToNew);\n}\n\n/**\n * Bulk update 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 // setup query params\n let localQuery: { allow_onetimes?: boolean } | undefined = undefined;\n if (query?.allow_onetimes !== undefined) {\n localQuery = { allow_onetimes: query.allow_onetimes };\n }\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 query: localQuery,\n },\n getInternalSession(session, 'updateSubscriptions')\n );\n return subscriptions.map(subscriptionMapperOldToNew);\n}\n\n/**\n * @internal\n * Bulk delete subscriptions.\n * Must all be for the same address.\n * There is a limit of 20 subscriptions per request.\n */\nexport async function deleteSubscriptions(\n session: Session,\n addressId: string | number,\n deleteRequestBulk: DeleteSubscriptionsRequest[],\n query?: DeleteSubscriptionsParams\n): Promise<void> {\n // validate size\n const length = deleteRequestBulk.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 // setup query params\n let localQuery: { allow_onetimes?: boolean } | undefined = undefined;\n if (query?.allow_onetimes !== undefined) {\n localQuery = { allow_onetimes: query.allow_onetimes };\n }\n await rechargeApiRequest<{ subscriptions: Subscription_2021_01[] }>(\n 'delete',\n `/addresses/${addressId}/subscriptions-bulk`,\n {\n data: { subscriptions: deleteRequestBulk, send_email: query?.send_email ?? false },\n headers: {\n 'X-Recharge-Version': '2021-01',\n },\n query: localQuery,\n },\n getInternalSession(session, 'deleteSubscriptions')\n );\n return undefined;\n}\n"],"names":["rechargeApiRequest","getInternalSession","bulkSubscriptionCreateMapper","subscriptionMapperOldToNew","bulkSubscriptionUpdateMapper"],"mappings":";;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AAA,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;AAEA,EAAA,IAAI,UAAuD,GAAA,KAAA,CAAA,CAAA;AAC3D,EAAI,IAAA,KAAA,EAAO,mBAAmB,KAAW,CAAA,EAAA;AACvC,IAAa,UAAA,GAAA,EAAE,cAAgB,EAAA,KAAA,CAAM,cAAe,EAAA,CAAA;AAAA,GACtD;AACA,EAAM,MAAAH,0BAAA;AAAA,IACJ,QAAA;AAAA,IACA,cAAc,SAAS,CAAA,mBAAA,CAAA;AAAA,IACvB;AAAA,MACE,MAAM,EAAE,aAAA,EAAe,mBAAmB,UAAY,EAAA,KAAA,EAAO,cAAc,KAAM,EAAA;AAAA,MACjF,OAAS,EAAA;AAAA,QACP,oBAAsB,EAAA,SAAA;AAAA,OACxB;AAAA,MACA,KAAO,EAAA,UAAA;AAAA,KACT;AAAA,IACAC,0BAAA,CAAmB,SAAS,qBAAqB,CAAA;AAAA,GACnD,CAAA;AACA,EAAO,OAAA,KAAA,CAAA,CAAA;AACT;;;;;;;;;;;;;;;;"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -112,6 +112,7 @@ exports.activateSubscription = subscription.activateSubscription;
|
|
|
112
112
|
exports.cancelSubscription = subscription.cancelSubscription;
|
|
113
113
|
exports.createSubscription = subscription.createSubscription;
|
|
114
114
|
exports.createSubscriptions = subscription.createSubscriptions;
|
|
115
|
+
exports.deleteSubscriptions = subscription.deleteSubscriptions;
|
|
115
116
|
exports.getSubscription = subscription.getSubscription;
|
|
116
117
|
exports.listSubscriptions = subscription.listSubscriptions;
|
|
117
118
|
exports.skipGiftSubscriptionCharge = subscription.skipGiftSubscriptionCharge;
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -35,7 +35,7 @@ async function rechargeApiRequest(method, url, { id, query, data, headers } = {}
|
|
|
35
35
|
"X-Recharge-Sdk-Fn": session.internalFnCall,
|
|
36
36
|
...appName ? { "X-Recharge-Sdk-App-Name": appName } : {},
|
|
37
37
|
...appVersion ? { "X-Recharge-Sdk-App-Version": appVersion } : {},
|
|
38
|
-
"X-Recharge-Sdk-Version": "1.
|
|
38
|
+
"X-Recharge-Sdk-Version": "1.25.0",
|
|
39
39
|
"X-Request-Id": session.internalRequestId,
|
|
40
40
|
...headers ? headers : {}
|
|
41
41
|
};
|
package/dist/esm/api/auth.js
CHANGED
|
@@ -140,7 +140,7 @@ async function rechargeAdminRequest(method, url, { id, query, data, headers } =
|
|
|
140
140
|
...storefrontAccessToken ? { "X-Recharge-Storefront-Access-Token": storefrontAccessToken } : {},
|
|
141
141
|
...appName ? { "X-Recharge-Sdk-App-Name": appName } : {},
|
|
142
142
|
...appVersion ? { "X-Recharge-Sdk-App-Version": appVersion } : {},
|
|
143
|
-
"X-Recharge-Sdk-Version": "1.
|
|
143
|
+
"X-Recharge-Sdk-Version": "1.25.0",
|
|
144
144
|
...headers ? headers : {}
|
|
145
145
|
};
|
|
146
146
|
return request(method, `${rechargeBaseUrl}${url}`, { id, query, data, headers: reqHeaders });
|
|
@@ -177,6 +177,33 @@ async function updateSubscriptions(session, addressId, updateRequestBulk, query)
|
|
|
177
177
|
);
|
|
178
178
|
return subscriptions.map(subscriptionMapperOldToNew);
|
|
179
179
|
}
|
|
180
|
+
async function deleteSubscriptions(session, addressId, deleteRequestBulk, query) {
|
|
181
|
+
const length = deleteRequestBulk.length;
|
|
182
|
+
if (length < 1 || length > 21) {
|
|
183
|
+
throw new Error("Number of subscriptions must be between 1 and 20.");
|
|
184
|
+
}
|
|
185
|
+
const { customerId } = session;
|
|
186
|
+
if (!customerId) {
|
|
187
|
+
throw new Error("No customerId in session.");
|
|
188
|
+
}
|
|
189
|
+
let localQuery = void 0;
|
|
190
|
+
if (query?.allow_onetimes !== void 0) {
|
|
191
|
+
localQuery = { allow_onetimes: query.allow_onetimes };
|
|
192
|
+
}
|
|
193
|
+
await rechargeApiRequest(
|
|
194
|
+
"delete",
|
|
195
|
+
`/addresses/${addressId}/subscriptions-bulk`,
|
|
196
|
+
{
|
|
197
|
+
data: { subscriptions: deleteRequestBulk, send_email: query?.send_email ?? false },
|
|
198
|
+
headers: {
|
|
199
|
+
"X-Recharge-Version": "2021-01"
|
|
200
|
+
},
|
|
201
|
+
query: localQuery
|
|
202
|
+
},
|
|
203
|
+
getInternalSession(session, "deleteSubscriptions")
|
|
204
|
+
);
|
|
205
|
+
return void 0;
|
|
206
|
+
}
|
|
180
207
|
|
|
181
|
-
export { activateSubscription, cancelSubscription, createSubscription, createSubscriptions, getSubscription, listSubscriptions, skipGiftSubscriptionCharge, skipSubscriptionCharge, updateSubscription, updateSubscriptionAddress, updateSubscriptionChargeDate, updateSubscriptions };
|
|
208
|
+
export { activateSubscription, cancelSubscription, createSubscription, createSubscriptions, deleteSubscriptions, getSubscription, listSubscriptions, skipGiftSubscriptionCharge, skipSubscriptionCharge, updateSubscription, updateSubscriptionAddress, updateSubscriptionChargeDate, updateSubscriptions };
|
|
182
209
|
//# sourceMappingURL=subscription.js.map
|
|
@@ -1 +1 @@
|
|
|
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 CreateSubscriptionsParams,\n CreateSubscriptionsRequest,\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: CreateSubscriptionsRequest[],\n query?: CreateSubscriptionsParams\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 query,\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 // setup query params\n let localQuery: { allow_onetimes?: boolean } | undefined = undefined;\n if (query?.allow_onetimes !== undefined) {\n localQuery = { allow_onetimes: query.allow_onetimes };\n }\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 query: localQuery,\n },\n getInternalSession(session, 'updateSubscriptions')\n );\n return subscriptions.map(subscriptionMapperOldToNew);\n}\n"],"names":[],"mappings":";;;;AA6BsB,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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CAAA,CAAA;AAEvE,EAAA,IAAI,UAAuD,GAAA,KAAA,CAAA,CAAA;AAC3D,EAAI,IAAA,KAAA,EAAO,mBAAmB,KAAW,CAAA,EAAA;AACvC,IAAa,UAAA,GAAA,EAAE,cAAgB,EAAA,KAAA,CAAM,cAAe,EAAA,CAAA;AAAA,GACtD;AACA,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,MACA,KAAO,EAAA,UAAA;AAAA,KACT;AAAA,IACA,kBAAA,CAAmB,SAAS,qBAAqB,CAAA;AAAA,GACnD,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 CreateSubscriptionsParams,\n CreateSubscriptionsRequest,\n DeleteSubscriptionsParams,\n DeleteSubscriptionsRequest,\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: CreateSubscriptionsRequest[],\n query?: CreateSubscriptionsParams\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 query,\n },\n getInternalSession(session, 'createSubscriptions')\n );\n return subscriptions.map(subscriptionMapperOldToNew);\n}\n\n/**\n * Bulk update 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 // setup query params\n let localQuery: { allow_onetimes?: boolean } | undefined = undefined;\n if (query?.allow_onetimes !== undefined) {\n localQuery = { allow_onetimes: query.allow_onetimes };\n }\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 query: localQuery,\n },\n getInternalSession(session, 'updateSubscriptions')\n );\n return subscriptions.map(subscriptionMapperOldToNew);\n}\n\n/**\n * @internal\n * Bulk delete subscriptions.\n * Must all be for the same address.\n * There is a limit of 20 subscriptions per request.\n */\nexport async function deleteSubscriptions(\n session: Session,\n addressId: string | number,\n deleteRequestBulk: DeleteSubscriptionsRequest[],\n query?: DeleteSubscriptionsParams\n): Promise<void> {\n // validate size\n const length = deleteRequestBulk.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 // setup query params\n let localQuery: { allow_onetimes?: boolean } | undefined = undefined;\n if (query?.allow_onetimes !== undefined) {\n localQuery = { allow_onetimes: query.allow_onetimes };\n }\n await rechargeApiRequest<{ subscriptions: Subscription_2021_01[] }>(\n 'delete',\n `/addresses/${addressId}/subscriptions-bulk`,\n {\n data: { subscriptions: deleteRequestBulk, send_email: query?.send_email ?? false },\n headers: {\n 'X-Recharge-Version': '2021-01',\n },\n query: localQuery,\n },\n getInternalSession(session, 'deleteSubscriptions')\n );\n return undefined;\n}\n"],"names":[],"mappings":";;;;AA+BsB,eAAA,eAAA,CACpB,OACA,EAAA,EAA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C,UAAY,EAAA;AACf,IAAM,MAAA,IAAI,MAAM,2BAA2B,CAAA,CAAA;AAAA,GAC7C;AAEA,EAAA,IAAI,UAAuD,GAAA,KAAA,CAAA,CAAA;AAC3D,EAAI,IAAA,KAAA,EAAO,mBAAmB,KAAW,CAAA,EAAA;AACvC,IAAa,UAAA,GAAA,EAAE,cAAgB,EAAA,KAAA,CAAM,cAAe,EAAA,CAAA;AAAA,GACtD;AACA,EAAM,MAAA,kBAAA;AAAA,IACJ,QAAA;AAAA,IACA,cAAc,SAAS,CAAA,mBAAA,CAAA;AAAA,IACvB;AAAA,MACE,MAAM,EAAE,aAAA,EAAe,mBAAmB,UAAY,EAAA,KAAA,EAAO,cAAc,KAAM,EAAA;AAAA,MACjF,OAAS,EAAA;AAAA,QACP,oBAAsB,EAAA,SAAA;AAAA,OACxB;AAAA,MACA,KAAO,EAAA,UAAA;AAAA,KACT;AAAA,IACA,kBAAA,CAAmB,SAAS,qBAAqB,CAAA;AAAA,GACnD,CAAA;AACA,EAAO,OAAA,KAAA,CAAA,CAAA;AACT;;;;"}
|
package/dist/esm/index.js
CHANGED
|
@@ -16,6 +16,6 @@ export { createPaymentMethod, getPaymentMethod, listPaymentMethods, updatePaymen
|
|
|
16
16
|
export { getPlan, listPlans } from './api/plan.js';
|
|
17
17
|
export { productSearch } from './api/product.js';
|
|
18
18
|
export { getShippingCountries, getStoreSettings } from './api/store.js';
|
|
19
|
-
export { activateSubscription, cancelSubscription, createSubscription, createSubscriptions, getSubscription, listSubscriptions, skipGiftSubscriptionCharge, skipSubscriptionCharge, updateSubscription, updateSubscriptionAddress, updateSubscriptionChargeDate, updateSubscriptions } from './api/subscription.js';
|
|
19
|
+
export { activateSubscription, cancelSubscription, createSubscription, createSubscriptions, deleteSubscriptions, getSubscription, listSubscriptions, skipGiftSubscriptionCharge, skipSubscriptionCharge, updateSubscription, updateSubscriptionAddress, updateSubscriptionChargeDate, updateSubscriptions } from './api/subscription.js';
|
|
20
20
|
export { api, initRecharge } from './utils/init.js';
|
|
21
21
|
//# sourceMappingURL=index.js.map
|
|
@@ -33,7 +33,7 @@ async function rechargeApiRequest(method, url, { id, query, data, headers } = {}
|
|
|
33
33
|
"X-Recharge-Sdk-Fn": session.internalFnCall,
|
|
34
34
|
...appName ? { "X-Recharge-Sdk-App-Name": appName } : {},
|
|
35
35
|
...appVersion ? { "X-Recharge-Sdk-App-Version": appVersion } : {},
|
|
36
|
-
"X-Recharge-Sdk-Version": "1.
|
|
36
|
+
"X-Recharge-Sdk-Version": "1.25.0",
|
|
37
37
|
"X-Request-Id": session.internalRequestId,
|
|
38
38
|
...headers ? headers : {}
|
|
39
39
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ interface SubscriptionPreferences {
|
|
|
29
29
|
order_interval_frequency: number | null;
|
|
30
30
|
pricing_progression: PlanPricingProgression[];
|
|
31
31
|
}
|
|
32
|
-
type PlanType = 'prepaid' | 'subscription' | 'onetime' | 'membership_subscription';
|
|
32
|
+
type PlanType = 'prepaid' | 'prepaid_v2' | 'subscription' | 'onetime' | 'membership_subscription';
|
|
33
33
|
interface Plan {
|
|
34
34
|
/** Unique numeric identifier for the Plan. */
|
|
35
35
|
id: number;
|
|
@@ -605,7 +605,7 @@ interface BundleData {
|
|
|
605
605
|
};
|
|
606
606
|
}
|
|
607
607
|
|
|
608
|
-
type SubscriptionStatus = 'active' | 'cancelled' | 'expired';
|
|
608
|
+
type SubscriptionStatus = 'active' | 'cancelled' | 'expired' | 'onetime';
|
|
609
609
|
interface Subscription {
|
|
610
610
|
/** Unique numeric identifier for the subscription. */
|
|
611
611
|
id: number;
|
|
@@ -626,7 +626,7 @@ interface Subscription {
|
|
|
626
626
|
* Charges must use the same unit types as orders.
|
|
627
627
|
* Max: 1000
|
|
628
628
|
*/
|
|
629
|
-
charge_interval_frequency: number;
|
|
629
|
+
charge_interval_frequency: number | null;
|
|
630
630
|
/** The time the subscription was created. */
|
|
631
631
|
created_at: IsoDateString;
|
|
632
632
|
/** Set the number of charges until subscription expires. */
|
|
@@ -646,7 +646,7 @@ interface Subscription {
|
|
|
646
646
|
/** Retrieves true if charge has an error max retries reached. Otherwise, retrieves false. */
|
|
647
647
|
max_retries_reached: boolean;
|
|
648
648
|
/** Date of the next charge for the subscription. */
|
|
649
|
-
next_charge_scheduled_at: IsoDateString;
|
|
649
|
+
next_charge_scheduled_at: IsoDateString | null;
|
|
650
650
|
/**
|
|
651
651
|
* The set day of the month order is created. Default is that there isn’t a strict day of the month when the order is created.
|
|
652
652
|
* This is only applicable to subscriptions with order_interval_unit:“month”.
|
|
@@ -661,9 +661,9 @@ interface Subscription {
|
|
|
661
661
|
/**
|
|
662
662
|
* The number of units (specified in order_interval_unit) between each order. For example, order_interval_unit=month and order_interval_frequency=3, indicate order every 3 months. Max value: 1000
|
|
663
663
|
*/
|
|
664
|
-
order_interval_frequency: number;
|
|
664
|
+
order_interval_frequency: number | null;
|
|
665
665
|
/** The frequency unit used to determine when a subscription’s order is created. */
|
|
666
|
-
order_interval_unit: IntervalUnit;
|
|
666
|
+
order_interval_unit: IntervalUnit | null;
|
|
667
667
|
/** The presentment currency of the subscription. */
|
|
668
668
|
presentment_currency: string | null;
|
|
669
669
|
/** The price of the item before discounts, taxes, or shipping have been applied. */
|
|
@@ -686,7 +686,7 @@ interface Subscription {
|
|
|
686
686
|
/** The date time at which the purchase_item record was last updated. */
|
|
687
687
|
updated_at: IsoDateString;
|
|
688
688
|
/** The name of the variant in a shop’s catalog. */
|
|
689
|
-
variant_title: string;
|
|
689
|
+
variant_title: string | null;
|
|
690
690
|
/** Additional information as requested */
|
|
691
691
|
include?: {
|
|
692
692
|
address?: Address;
|
|
@@ -764,6 +764,13 @@ interface UpdateSubscriptionParams extends BasicSubscriptionParams {
|
|
|
764
764
|
/** If set to True, updates will also be applied to CANCELLED subscriptions. If null or False, only ACTIVE subscriptions will be updated. */
|
|
765
765
|
force_update?: boolean;
|
|
766
766
|
}
|
|
767
|
+
/** @internal */
|
|
768
|
+
interface DeleteSubscriptionsParams {
|
|
769
|
+
/** Allows onetimes to be updated with subscriptions */
|
|
770
|
+
allow_onetimes?: boolean;
|
|
771
|
+
/** When your store setting indicates that cancellation emails should be sent, this value determines if subscription cancellation emails should be sent. If set to true, cancellation emails will be sent for each of the specified subscriptions. If set to false, cancellation emails will not be sent for any of the specified subscriptions. */
|
|
772
|
+
send_email?: boolean;
|
|
773
|
+
}
|
|
767
774
|
interface CancelSubscriptionRequest {
|
|
768
775
|
cancellation_reason: string;
|
|
769
776
|
cancellation_reason_comments?: string;
|
|
@@ -775,6 +782,10 @@ interface UpdateSubscriptionsRequest extends Omit<UpdateSubscriptionRequest, 'pl
|
|
|
775
782
|
id: Subscription['id'];
|
|
776
783
|
address_id?: Subscription['address_id'];
|
|
777
784
|
}
|
|
785
|
+
/** @internal */
|
|
786
|
+
interface DeleteSubscriptionsRequest {
|
|
787
|
+
id: Subscription['id'];
|
|
788
|
+
}
|
|
778
789
|
interface Subscription_2021_01 {
|
|
779
790
|
is_prepaid: boolean;
|
|
780
791
|
order_day_of_month: number | null;
|
|
@@ -2897,12 +2908,19 @@ declare function skipGiftSubscriptionCharge(session: Session, subscriptionIds: A
|
|
|
2897
2908
|
*/
|
|
2898
2909
|
declare function createSubscriptions(session: Session, createRequestBulk: CreateSubscriptionsRequest[], query?: CreateSubscriptionsParams): Promise<Subscription[]>;
|
|
2899
2910
|
/**
|
|
2900
|
-
* Bulk
|
|
2911
|
+
* Bulk update subscriptions.
|
|
2901
2912
|
* Must all be for the same address.
|
|
2902
2913
|
* There is a limit of 20 subscriptions per request.
|
|
2903
2914
|
* Same rules apply as a single subscription update
|
|
2904
2915
|
*/
|
|
2905
2916
|
declare function updateSubscriptions(session: Session, addressId: string | number, updateRequestBulk: UpdateSubscriptionsRequest[], query?: UpdateSubscriptionsParams): Promise<Subscription[]>;
|
|
2917
|
+
/**
|
|
2918
|
+
* @internal
|
|
2919
|
+
* Bulk delete subscriptions.
|
|
2920
|
+
* Must all be for the same address.
|
|
2921
|
+
* There is a limit of 20 subscriptions per request.
|
|
2922
|
+
*/
|
|
2923
|
+
declare function deleteSubscriptions(session: Session, addressId: string | number, deleteRequestBulk: DeleteSubscriptionsRequest[], query?: DeleteSubscriptionsParams): Promise<void>;
|
|
2906
2924
|
|
|
2907
2925
|
/**
|
|
2908
2926
|
* @internal
|
|
@@ -2916,4 +2934,4 @@ declare const api: {
|
|
|
2916
2934
|
};
|
|
2917
2935
|
declare function initRecharge(opt?: InitOptions): void;
|
|
2918
2936
|
|
|
2919
|
-
export { type ActivateMembershipRequest, type AddToCartCallbackSettings, type AddonSettings, type Address, type AddressIncludes, type AddressListParams, type AddressListResponse, type AddressResponse, type AddressSortBy, type AnalyticsData, type ApplyCreditOptions, type AssociatedAddress, type BasicSubscriptionParams, type BooleanLike, type BooleanNumbers, type BooleanString, type BooleanStringNumbers, type BundleAppProxy, type BundleData, 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 CreateSubscriptionsParams, type CreateSubscriptionsRequest, type CreditAccount, type CreditAccountIncludes, type CreditAccountListParams, type CreditAccountType, type CreditAccountsResponse, type CreditAccountsSortBy, type CreditSummaryIncludes, type CrossSellsSettings, type Customer, type CustomerCreditSummary, type CustomerDeliveryScheduleParams, type CustomerDeliveryScheduleResponse, type CustomerIncludes, type CustomerNotification, type CustomerNotificationOptions, type CustomerNotificationTemplate, type CustomerNotificationType, type CustomerPortalAccessOptions, type CustomerPortalAccessResponse, type CustomerPortalSettings, 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 OfferAttributes, 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 StoreSettings, 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, getStoreSettings, getSubscription, initRecharge, type intervalUnit, listAddresses, listBundleSelections, listCharges, listCollectionProducts, listCollections, listCreditAccounts, listGiftPurchases, listMembershipPrograms, listMemberships, listOnetimes, listOrders, listPaymentMethods, listPlans, listSubscriptions, loginCustomerPortal, loginShopifyApi, loginShopifyAppProxy, loginWithShopifyCustomerAccount, loginWithShopifyStorefront, type membershipIncludes, mergeAddresses, processCharge, productSearch, removeDiscountsFromAddress, removeDiscountsFromCharge, resetCDNCache, sendCustomerNotification, sendPasswordlessCode, sendPasswordlessCodeAppProxy, setApplyCreditsToNextCharge, skipCharge, skipFutureCharge, skipGiftSubscriptionCharge, skipSubscriptionCharge, unskipCharge, updateAddress, updateBundle, updateBundleSelection, updateCustomer, updateMetafield, updateOnetime, updatePaymentMethod, updateSubscription, updateSubscriptionAddress, updateSubscriptionChargeDate, updateSubscriptions, validateBundle, validateBundleSelection, validateDynamicBundle, validatePasswordlessCode, validatePasswordlessCodeAppProxy };
|
|
2937
|
+
export { type ActivateMembershipRequest, type AddToCartCallbackSettings, type AddonSettings, type Address, type AddressIncludes, type AddressListParams, type AddressListResponse, type AddressResponse, type AddressSortBy, type AnalyticsData, type ApplyCreditOptions, type AssociatedAddress, type BasicSubscriptionParams, type BooleanLike, type BooleanNumbers, type BooleanString, type BooleanStringNumbers, type BundleAppProxy, type BundleData, 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 CreateSubscriptionsParams, type CreateSubscriptionsRequest, type CreditAccount, type CreditAccountIncludes, type CreditAccountListParams, type CreditAccountType, type CreditAccountsResponse, type CreditAccountsSortBy, type CreditSummaryIncludes, type CrossSellsSettings, type Customer, type CustomerCreditSummary, type CustomerDeliveryScheduleParams, type CustomerDeliveryScheduleResponse, type CustomerIncludes, type CustomerNotification, type CustomerNotificationOptions, type CustomerNotificationTemplate, type CustomerNotificationType, type CustomerPortalAccessOptions, type CustomerPortalAccessResponse, type CustomerPortalSettings, type DeleteSubscriptionsParams, type DeleteSubscriptionsRequest, 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 OfferAttributes, 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 StoreSettings, 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, deleteSubscriptions, 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, getStoreSettings, getSubscription, initRecharge, type intervalUnit, listAddresses, listBundleSelections, listCharges, listCollectionProducts, listCollections, listCreditAccounts, listGiftPurchases, listMembershipPrograms, listMemberships, listOnetimes, listOrders, listPaymentMethods, listPlans, listSubscriptions, loginCustomerPortal, loginShopifyApi, loginShopifyAppProxy, loginWithShopifyCustomerAccount, loginWithShopifyStorefront, type membershipIncludes, mergeAddresses, processCharge, productSearch, removeDiscountsFromAddress, removeDiscountsFromCharge, resetCDNCache, sendCustomerNotification, sendPasswordlessCode, sendPasswordlessCodeAppProxy, setApplyCreditsToNextCharge, skipCharge, skipFutureCharge, skipGiftSubscriptionCharge, skipSubscriptionCharge, unskipCharge, updateAddress, updateBundle, updateBundleSelection, updateCustomer, updateMetafield, updateOnetime, updatePaymentMethod, updateSubscription, updateSubscriptionAddress, updateSubscriptionChargeDate, updateSubscriptions, validateBundle, validateBundleSelection, validateDynamicBundle, validatePasswordlessCode, validatePasswordlessCodeAppProxy };
|