@rechargeapps/storefront-client 1.23.0 → 1.24.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/store.js +15 -0
- package/dist/cjs/api/store.js.map +1 -1
- 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/store.js +15 -1
- package/dist/esm/api/store.js.map +1 -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 +134 -4
- package/dist/umd/recharge-client.min.js +4 -4
- 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.24.0",
|
|
146
146
|
...headers ? headers : {}
|
|
147
147
|
};
|
|
148
148
|
return request.request(method, `${rechargeBaseUrl}${url}`, { id, query, data, headers: reqHeaders });
|
package/dist/cjs/api/store.js
CHANGED
|
@@ -17,6 +17,21 @@ async function getShippingCountries(session, options) {
|
|
|
17
17
|
);
|
|
18
18
|
return response;
|
|
19
19
|
}
|
|
20
|
+
async function getStoreSettings(session) {
|
|
21
|
+
const response = await request.rechargeApiRequest(
|
|
22
|
+
"get",
|
|
23
|
+
"/shop/settings",
|
|
24
|
+
{
|
|
25
|
+
headers: {
|
|
26
|
+
// Currently this is only available on the older api version.
|
|
27
|
+
"X-Recharge-Version": "2021-01"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
request.getInternalSession(session, "getStoreSettings")
|
|
31
|
+
);
|
|
32
|
+
return response;
|
|
33
|
+
}
|
|
20
34
|
|
|
21
35
|
exports.getShippingCountries = getShippingCountries;
|
|
36
|
+
exports.getStoreSettings = getStoreSettings;
|
|
22
37
|
//# sourceMappingURL=store.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.js","sources":["../../../src/api/store.ts"],"sourcesContent":["import { ShippingCountriesOptions, ShippingCountriesResponse, Session } from '../types';\nimport { getInternalSession, rechargeApiRequest } from '../utils/request';\n\n/**\n * Get a list of all shipping countries for the store.\n */\nexport async function getShippingCountries(\n session: Session,\n options?: ShippingCountriesOptions\n): Promise<ShippingCountriesResponse> {\n const response = await rechargeApiRequest<ShippingCountriesResponse>(\n 'get',\n `/shop/shipping_countries`,\n {\n query: options,\n headers: {\n // Currently this is only available on the older api version.\n 'X-Recharge-Version': '2021-01',\n },\n },\n getInternalSession(session, 'getShippingCountries')\n );\n return response;\n}\n"],"names":["rechargeApiRequest","getInternalSession"],"mappings":";;;;AAMsB,eAAA,oBAAA,CACpB,SACA,OACoC,EAAA;AACpC,EAAA,MAAM,WAAW,MAAMA,0BAAA;AAAA,IACrB,KAAA;AAAA,IACA,CAAA,wBAAA,CAAA;AAAA,IACA;AAAA,MACE,KAAO,EAAA,OAAA;AAAA,MACP,OAAS,EAAA;AAAA;AAAA,QAEP,oBAAsB,EAAA,SAAA;AAAA,OACxB;AAAA,KACF;AAAA,IACAC,0BAAA,CAAmB,SAAS,sBAAsB,CAAA;AAAA,GACpD,CAAA;AACA,EAAO,OAAA,QAAA,CAAA;AACT
|
|
1
|
+
{"version":3,"file":"store.js","sources":["../../../src/api/store.ts"],"sourcesContent":["import { ShippingCountriesOptions, ShippingCountriesResponse, StoreSettings, Session } from '../types';\nimport { getInternalSession, rechargeApiRequest } from '../utils/request';\n\n/**\n * Get a list of all shipping countries for the store.\n */\nexport async function getShippingCountries(\n session: Session,\n options?: ShippingCountriesOptions\n): Promise<ShippingCountriesResponse> {\n const response = await rechargeApiRequest<ShippingCountriesResponse>(\n 'get',\n `/shop/shipping_countries`,\n {\n query: options,\n headers: {\n // Currently this is only available on the older api version.\n 'X-Recharge-Version': '2021-01',\n },\n },\n getInternalSession(session, 'getShippingCountries')\n );\n return response;\n}\n\n/**\n * Get the settings of the store. This includes the Customer Portal settings.\n */\nexport async function getStoreSettings(session: Session): Promise<StoreSettings> {\n const response = await rechargeApiRequest<StoreSettings>(\n 'get',\n '/shop/settings',\n {\n headers: {\n // Currently this is only available on the older api version.\n 'X-Recharge-Version': '2021-01',\n },\n },\n getInternalSession(session, 'getStoreSettings')\n );\n return response;\n}\n"],"names":["rechargeApiRequest","getInternalSession"],"mappings":";;;;AAMsB,eAAA,oBAAA,CACpB,SACA,OACoC,EAAA;AACpC,EAAA,MAAM,WAAW,MAAMA,0BAAA;AAAA,IACrB,KAAA;AAAA,IACA,CAAA,wBAAA,CAAA;AAAA,IACA;AAAA,MACE,KAAO,EAAA,OAAA;AAAA,MACP,OAAS,EAAA;AAAA;AAAA,QAEP,oBAAsB,EAAA,SAAA;AAAA,OACxB;AAAA,KACF;AAAA,IACAC,0BAAA,CAAmB,SAAS,sBAAsB,CAAA;AAAA,GACpD,CAAA;AACA,EAAO,OAAA,QAAA,CAAA;AACT,CAAA;AAKA,eAAsB,iBAAiB,OAA0C,EAAA;AAC/E,EAAA,MAAM,WAAW,MAAMD,0BAAA;AAAA,IACrB,KAAA;AAAA,IACA,gBAAA;AAAA,IACA;AAAA,MACE,OAAS,EAAA;AAAA;AAAA,QAEP,oBAAsB,EAAA,SAAA;AAAA,OACxB;AAAA,KACF;AAAA,IACAC,0BAAA,CAAmB,SAAS,kBAAkB,CAAA;AAAA,GAChD,CAAA;AACA,EAAO,OAAA,QAAA,CAAA;AACT;;;;;"}
|
|
@@ -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} 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 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":";;;;;;AA4BsB,eAAA,eAAA,CACpB,OACA,EAAA,EAAA,EACA,OACuB,EAAA;AACvB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M,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,CAAAC,yCAAA,EAA8B,CAAC,CAAC,OAAO,YAAY,CAAA,CAAA;AACjG,EAAM,MAAA,WAAA,GAAc,iBAAkB,CAAA,GAAA,CAAI,6BAA6B,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,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} 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;A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AAA,CAAI,6BAA6B,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,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;;;;;;;;;;;;;;;"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -107,6 +107,7 @@ exports.getPlan = plan.getPlan;
|
|
|
107
107
|
exports.listPlans = plan.listPlans;
|
|
108
108
|
exports.productSearch = product.productSearch;
|
|
109
109
|
exports.getShippingCountries = store.getShippingCountries;
|
|
110
|
+
exports.getStoreSettings = store.getStoreSettings;
|
|
110
111
|
exports.activateSubscription = subscription.activateSubscription;
|
|
111
112
|
exports.cancelSubscription = subscription.cancelSubscription;
|
|
112
113
|
exports.createSubscription = subscription.createSubscription;
|
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.24.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.24.0",
|
|
144
144
|
...headers ? headers : {}
|
|
145
145
|
};
|
|
146
146
|
return request(method, `${rechargeBaseUrl}${url}`, { id, query, data, headers: reqHeaders });
|
package/dist/esm/api/store.js
CHANGED
|
@@ -15,6 +15,20 @@ async function getShippingCountries(session, options) {
|
|
|
15
15
|
);
|
|
16
16
|
return response;
|
|
17
17
|
}
|
|
18
|
+
async function getStoreSettings(session) {
|
|
19
|
+
const response = await rechargeApiRequest(
|
|
20
|
+
"get",
|
|
21
|
+
"/shop/settings",
|
|
22
|
+
{
|
|
23
|
+
headers: {
|
|
24
|
+
// Currently this is only available on the older api version.
|
|
25
|
+
"X-Recharge-Version": "2021-01"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
getInternalSession(session, "getStoreSettings")
|
|
29
|
+
);
|
|
30
|
+
return response;
|
|
31
|
+
}
|
|
18
32
|
|
|
19
|
-
export { getShippingCountries };
|
|
33
|
+
export { getShippingCountries, getStoreSettings };
|
|
20
34
|
//# sourceMappingURL=store.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.js","sources":["../../../src/api/store.ts"],"sourcesContent":["import { ShippingCountriesOptions, ShippingCountriesResponse, Session } from '../types';\nimport { getInternalSession, rechargeApiRequest } from '../utils/request';\n\n/**\n * Get a list of all shipping countries for the store.\n */\nexport async function getShippingCountries(\n session: Session,\n options?: ShippingCountriesOptions\n): Promise<ShippingCountriesResponse> {\n const response = await rechargeApiRequest<ShippingCountriesResponse>(\n 'get',\n `/shop/shipping_countries`,\n {\n query: options,\n headers: {\n // Currently this is only available on the older api version.\n 'X-Recharge-Version': '2021-01',\n },\n },\n getInternalSession(session, 'getShippingCountries')\n );\n return response;\n}\n"],"names":[],"mappings":";;AAMsB,eAAA,oBAAA,CACpB,SACA,OACoC,EAAA;AACpC,EAAA,MAAM,WAAW,MAAM,kBAAA;AAAA,IACrB,KAAA;AAAA,IACA,CAAA,wBAAA,CAAA;AAAA,IACA;AAAA,MACE,KAAO,EAAA,OAAA;AAAA,MACP,OAAS,EAAA;AAAA;AAAA,QAEP,oBAAsB,EAAA,SAAA;AAAA,OACxB;AAAA,KACF;AAAA,IACA,kBAAA,CAAmB,SAAS,sBAAsB,CAAA;AAAA,GACpD,CAAA;AACA,EAAO,OAAA,QAAA,CAAA;AACT;;;;"}
|
|
1
|
+
{"version":3,"file":"store.js","sources":["../../../src/api/store.ts"],"sourcesContent":["import { ShippingCountriesOptions, ShippingCountriesResponse, StoreSettings, Session } from '../types';\nimport { getInternalSession, rechargeApiRequest } from '../utils/request';\n\n/**\n * Get a list of all shipping countries for the store.\n */\nexport async function getShippingCountries(\n session: Session,\n options?: ShippingCountriesOptions\n): Promise<ShippingCountriesResponse> {\n const response = await rechargeApiRequest<ShippingCountriesResponse>(\n 'get',\n `/shop/shipping_countries`,\n {\n query: options,\n headers: {\n // Currently this is only available on the older api version.\n 'X-Recharge-Version': '2021-01',\n },\n },\n getInternalSession(session, 'getShippingCountries')\n );\n return response;\n}\n\n/**\n * Get the settings of the store. This includes the Customer Portal settings.\n */\nexport async function getStoreSettings(session: Session): Promise<StoreSettings> {\n const response = await rechargeApiRequest<StoreSettings>(\n 'get',\n '/shop/settings',\n {\n headers: {\n // Currently this is only available on the older api version.\n 'X-Recharge-Version': '2021-01',\n },\n },\n getInternalSession(session, 'getStoreSettings')\n );\n return response;\n}\n"],"names":[],"mappings":";;AAMsB,eAAA,oBAAA,CACpB,SACA,OACoC,EAAA;AACpC,EAAA,MAAM,WAAW,MAAM,kBAAA;AAAA,IACrB,KAAA;AAAA,IACA,CAAA,wBAAA,CAAA;AAAA,IACA;AAAA,MACE,KAAO,EAAA,OAAA;AAAA,MACP,OAAS,EAAA;AAAA;AAAA,QAEP,oBAAsB,EAAA,SAAA;AAAA,OACxB;AAAA,KACF;AAAA,IACA,kBAAA,CAAmB,SAAS,sBAAsB,CAAA;AAAA,GACpD,CAAA;AACA,EAAO,OAAA,QAAA,CAAA;AACT,CAAA;AAKA,eAAsB,iBAAiB,OAA0C,EAAA;AAC/E,EAAA,MAAM,WAAW,MAAM,kBAAA;AAAA,IACrB,KAAA;AAAA,IACA,gBAAA;AAAA,IACA;AAAA,MACE,OAAS,EAAA;AAAA;AAAA,QAEP,oBAAsB,EAAA,SAAA;AAAA,OACxB;AAAA,KACF;AAAA,IACA,kBAAA,CAAmB,SAAS,kBAAkB,CAAA;AAAA,GAChD,CAAA;AACA,EAAO,OAAA,QAAA,CAAA;AACT;;;;"}
|
|
@@ -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} 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 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":";;;;AA4BsB,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,CA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c,iBAAkB,CAAA,GAAA,CAAI,6BAA6B,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} 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,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,EAA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AAA,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;;;;"}
|
package/dist/esm/index.js
CHANGED
|
@@ -15,7 +15,7 @@ export { getOrder, listOrders } from './api/order.js';
|
|
|
15
15
|
export { createPaymentMethod, getPaymentMethod, listPaymentMethods, updatePaymentMethod } from './api/paymentMethod.js';
|
|
16
16
|
export { getPlan, listPlans } from './api/plan.js';
|
|
17
17
|
export { productSearch } from './api/product.js';
|
|
18
|
-
export { getShippingCountries } from './api/store.js';
|
|
18
|
+
export { getShippingCountries, getStoreSettings } from './api/store.js';
|
|
19
19
|
export { activateSubscription, cancelSubscription, createSubscription, createSubscriptions, 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.24.0",
|
|
37
37
|
"X-Request-Id": session.internalRequestId,
|
|
38
38
|
...headers ? headers : {}
|
|
39
39
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -736,9 +736,11 @@ interface CreateSubscriptionRequest extends SubType<Subscription, SubscriptionRe
|
|
|
736
736
|
* This will create the subscription using the credit account associated with the gift.
|
|
737
737
|
*/
|
|
738
738
|
gift_id?: number;
|
|
739
|
+
/** subscription plan_id - if included on create request then charge_interval_frequency/order_interval_frequency/order_interval_unit are not required */
|
|
740
|
+
plan_id?: Plan['id'];
|
|
739
741
|
}
|
|
740
742
|
interface UpdateSubscriptionRequest extends Partial<Pick<Subscription, 'charge_interval_frequency' | 'expire_after_specific_number_of_charges' | 'external_variant_id' | 'next_charge_scheduled_at' | 'order_day_of_month' | 'order_day_of_week' | 'order_interval_frequency' | 'order_interval_unit' | 'properties' | 'quantity'> & {
|
|
741
|
-
/** subscription plan_id - if included on update request then
|
|
743
|
+
/** subscription plan_id - if included on update request then charge_interval_frequency/order_interval_frequency/order_interval_unit are not required */
|
|
742
744
|
plan_id?: Plan['id'];
|
|
743
745
|
}> {
|
|
744
746
|
}
|
|
@@ -767,7 +769,9 @@ interface CancelSubscriptionRequest {
|
|
|
767
769
|
cancellation_reason_comments?: string;
|
|
768
770
|
send_email?: boolean;
|
|
769
771
|
}
|
|
770
|
-
interface
|
|
772
|
+
interface CreateSubscriptionsRequest extends Omit<CreateSubscriptionRequest, 'plan_id'> {
|
|
773
|
+
}
|
|
774
|
+
interface UpdateSubscriptionsRequest extends Omit<UpdateSubscriptionRequest, 'plan_id'> {
|
|
771
775
|
id: Subscription['id'];
|
|
772
776
|
address_id?: Subscription['address_id'];
|
|
773
777
|
}
|
|
@@ -2557,6 +2561,128 @@ interface ShippingCountry {
|
|
|
2557
2561
|
*/
|
|
2558
2562
|
provinces: ShippingProvince[];
|
|
2559
2563
|
}
|
|
2564
|
+
interface StoreSettings {
|
|
2565
|
+
settings: {
|
|
2566
|
+
/** The Recharge store ID. */
|
|
2567
|
+
shop_id: number;
|
|
2568
|
+
/** Settings related to the customer portal. */
|
|
2569
|
+
customer_portal: CustomerPortalSettings;
|
|
2570
|
+
/** The store uses Shopify Contracts or not. */
|
|
2571
|
+
has_shopify_connector: boolean;
|
|
2572
|
+
/** The store supports multiple currencies or not. */
|
|
2573
|
+
multicurrency_enabled: boolean;
|
|
2574
|
+
};
|
|
2575
|
+
}
|
|
2576
|
+
interface CustomerPortalSettings {
|
|
2577
|
+
/**
|
|
2578
|
+
* The Recharge collection IDs in case the products available for purchase are
|
|
2579
|
+
* limited to specific Recharge collections.
|
|
2580
|
+
* */
|
|
2581
|
+
collection_ids: number[];
|
|
2582
|
+
/** The filter of products that are available to create new subscriptions. */
|
|
2583
|
+
available_products: 'all' | 'specific_recharge_collections' | 'specific_plan_types';
|
|
2584
|
+
/** Whether the store is using Plans and Products or not. */
|
|
2585
|
+
can_use_plans: boolean;
|
|
2586
|
+
/** Whether the store is using collections with custom sorting or not. */
|
|
2587
|
+
collection_product_sorting_enabled: boolean;
|
|
2588
|
+
/** Allow the customer to add discount codes to their subscription. */
|
|
2589
|
+
discount_input: boolean;
|
|
2590
|
+
/** Allow the customer to modify the shipping address for an existing subscription. */
|
|
2591
|
+
edit_shipping_address: boolean;
|
|
2592
|
+
/** Whether flows are enabled or not. */
|
|
2593
|
+
flows_enabled: boolean;
|
|
2594
|
+
/** Whether customers can skip gift shipment or not. */
|
|
2595
|
+
gift_skipped_shipment_enabled: boolean;
|
|
2596
|
+
/** Settings related to gifting. */
|
|
2597
|
+
gifting: {
|
|
2598
|
+
/** Cancels the subscriptions when gifting finishes. */
|
|
2599
|
+
cancel_sub_on_gift_end: boolean;
|
|
2600
|
+
/** Whether gifting is enabled or not. */
|
|
2601
|
+
enabled: boolean;
|
|
2602
|
+
/** Fulfill the order when the gift is redeemed. */
|
|
2603
|
+
fulfill_orders_on_redemption: boolean;
|
|
2604
|
+
/** The platform where the gift redemption is happening. */
|
|
2605
|
+
redemption_ui_platform: string;
|
|
2606
|
+
/** Whether the customer can select onetime products when gifting or not. */
|
|
2607
|
+
select_onetime: number;
|
|
2608
|
+
/** Whether the customer can select the quantity when gifting or not. */
|
|
2609
|
+
select_quantity: number;
|
|
2610
|
+
};
|
|
2611
|
+
/** Whether gifting is enabled or not. */
|
|
2612
|
+
gifting_enabled: boolean;
|
|
2613
|
+
/** How does the store handles inventory policy **/
|
|
2614
|
+
inventory_behaviour: 'bypass' | 'decrement_ignoring_policy' | 'decrement_obeying_policy';
|
|
2615
|
+
/** Whether the customer can create a new address or use their default. */
|
|
2616
|
+
prevent_address_creation: boolean;
|
|
2617
|
+
/** Whether the customer can create a new payment method or use their default. */
|
|
2618
|
+
prevent_payment_method_creation: boolean;
|
|
2619
|
+
/** Settings related to credits. */
|
|
2620
|
+
recharge_credits_settings: {
|
|
2621
|
+
/** Contains the discount name. */
|
|
2622
|
+
discount_name: string;
|
|
2623
|
+
/** The strategy for obtaining credits. */
|
|
2624
|
+
recurring_redemption: string;
|
|
2625
|
+
};
|
|
2626
|
+
/** Whether to show credits or not. */
|
|
2627
|
+
show_credits: boolean;
|
|
2628
|
+
/** Subscription related settings */
|
|
2629
|
+
subscription: {
|
|
2630
|
+
/** Whether the customer can create new subscriptions or not. */
|
|
2631
|
+
add_product: boolean;
|
|
2632
|
+
/** Whether the customer can cancel their subscription or not. */
|
|
2633
|
+
cancel_subscription: boolean;
|
|
2634
|
+
/** The email to contact when cancelling a subscription. */
|
|
2635
|
+
cancellation_email_contact: string;
|
|
2636
|
+
/** Whether the customer can pause their subscriptions or not. */
|
|
2637
|
+
cancellation_enable_pause_options: boolean;
|
|
2638
|
+
/** The options for pausing a subscription. */
|
|
2639
|
+
cancellation_enable_pause_options_values: string;
|
|
2640
|
+
/** The minimum order count for cancelling a subscription. */
|
|
2641
|
+
cancellation_minimum_order_count: number;
|
|
2642
|
+
/** Whether the cancellation reason is optional or not. */
|
|
2643
|
+
cancellation_reason_optional: boolean;
|
|
2644
|
+
/** Whether the next charge should be recalculated when changing the frequency or not. */
|
|
2645
|
+
change_frequency_recalculate_next_charge: boolean;
|
|
2646
|
+
/** Whether the customer can swap the subscription product or not. */
|
|
2647
|
+
change_product: boolean;
|
|
2648
|
+
/** Whether the customer can change the quantity of the subscription or not. */
|
|
2649
|
+
change_quantity: boolean;
|
|
2650
|
+
/** Whether the customer can swap the variant of the subscription or not. */
|
|
2651
|
+
change_variant: boolean;
|
|
2652
|
+
/** Whether the customer can change the subscription frequency or not. */
|
|
2653
|
+
edit_order_frequency: string;
|
|
2654
|
+
/** Whether the customer can change the scheduled date for a charge or not. */
|
|
2655
|
+
edit_scheduled_date: boolean;
|
|
2656
|
+
/** Whether the customer can reactivate a cancelled subscription. */
|
|
2657
|
+
reactivate_subscription: boolean;
|
|
2658
|
+
/** Whether the customer can skip a prepaid order or not. */
|
|
2659
|
+
skip_prepaid_order: boolean;
|
|
2660
|
+
/** Whether the customer can skip a scheduled order or not. */
|
|
2661
|
+
skip_scheduled_order: boolean;
|
|
2662
|
+
/** Whether the customer can purchase a zero inventory product or not. */
|
|
2663
|
+
zero_inventory_purchase: boolean;
|
|
2664
|
+
};
|
|
2665
|
+
/** Uses the inventory level from Recharge as source of truth */
|
|
2666
|
+
use_recharge_inventory_levels: boolean;
|
|
2667
|
+
/** Use Spreedly instead of Shopify Payments when creating a new payment method. */
|
|
2668
|
+
use_spreedly_form_for_sci_payment_methods: boolean;
|
|
2669
|
+
/** The customer can see the order schedule */
|
|
2670
|
+
view_order_schedule: boolean;
|
|
2671
|
+
/** The customer can see the payment methods */
|
|
2672
|
+
view_recharge_payment_methods: boolean;
|
|
2673
|
+
/** The customer can see the subscriptions */
|
|
2674
|
+
view_subscriptions: boolean;
|
|
2675
|
+
/** Uses Flows Active Churn Recovery */
|
|
2676
|
+
wfs_active_churn: boolean;
|
|
2677
|
+
/** Should redirect to ACR landing page */
|
|
2678
|
+
wfs_active_churn_landing_page_redirect: boolean;
|
|
2679
|
+
/** Uses Flows Experiences */
|
|
2680
|
+
wfs_experiences_landing_page: boolean;
|
|
2681
|
+
/** Uses Flows */
|
|
2682
|
+
wfs_flows_enabled: boolean;
|
|
2683
|
+
/** Ignores restricted keywords for the store in Klaviyo */
|
|
2684
|
+
wfs_klaviyo_sender: boolean;
|
|
2685
|
+
}
|
|
2560
2686
|
|
|
2561
2687
|
/** Returns all addresses from the store, or addresses for the customer given in the parameter. */
|
|
2562
2688
|
declare function listAddresses(session: Session, query?: AddressListParams): Promise<AddressListResponse>;
|
|
@@ -2720,6 +2846,10 @@ declare function productSearch<T extends ProductSearchParams_2020_12 | ProductSe
|
|
|
2720
2846
|
* Get a list of all shipping countries for the store.
|
|
2721
2847
|
*/
|
|
2722
2848
|
declare function getShippingCountries(session: Session, options?: ShippingCountriesOptions): Promise<ShippingCountriesResponse>;
|
|
2849
|
+
/**
|
|
2850
|
+
* Get the settings of the store. This includes the Customer Portal settings.
|
|
2851
|
+
*/
|
|
2852
|
+
declare function getStoreSettings(session: Session): Promise<StoreSettings>;
|
|
2723
2853
|
|
|
2724
2854
|
declare function getSubscription(session: Session, id: string | number, options?: GetSubscriptionOptions): Promise<Subscription>;
|
|
2725
2855
|
declare function listSubscriptions(session: Session, query?: SubscriptionListParams): Promise<SubscriptionsResponse>;
|
|
@@ -2765,7 +2895,7 @@ declare function skipGiftSubscriptionCharge(session: Session, subscriptionIds: A
|
|
|
2765
2895
|
* Must all be for the same address.
|
|
2766
2896
|
* There is a limit of 20 subscriptions per request.
|
|
2767
2897
|
*/
|
|
2768
|
-
declare function createSubscriptions(session: Session, createRequestBulk:
|
|
2898
|
+
declare function createSubscriptions(session: Session, createRequestBulk: CreateSubscriptionsRequest[], query?: CreateSubscriptionsParams): Promise<Subscription[]>;
|
|
2769
2899
|
/**
|
|
2770
2900
|
* Bulk create new subscriptions.
|
|
2771
2901
|
* Must all be for the same address.
|
|
@@ -2786,4 +2916,4 @@ declare const api: {
|
|
|
2786
2916
|
};
|
|
2787
2917
|
declare function initRecharge(opt?: InitOptions): void;
|
|
2788
2918
|
|
|
2789
|
-
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 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 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 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, 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 };
|
|
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 };
|