@rechargeapps/storefront-client 1.18.3 → 1.19.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/credit.js +51 -0
- package/dist/cjs/api/credit.js.map +1 -0
- package/dist/cjs/api/customer.js +0 -16
- package/dist/cjs/api/customer.js.map +1 -1
- package/dist/cjs/index.js +4 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/api/credit.js +47 -0
- package/dist/esm/api/credit.js.map +1 -0
- package/dist/esm/api/customer.js +1 -16
- package/dist/esm/api/customer.js.map +1 -1
- package/dist/esm/index.js +2 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.ts +71 -45
- package/dist/umd/recharge-client.min.js +10 -10
- package/package.json +1 -1
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var request = require('../utils/request.js');
|
|
4
|
+
var customer = require('./customer.js');
|
|
5
|
+
|
|
6
|
+
async function getCreditSummary(session, options) {
|
|
7
|
+
const id = session.customerId;
|
|
8
|
+
if (!id) {
|
|
9
|
+
throw new Error("Not logged in.");
|
|
10
|
+
}
|
|
11
|
+
const { credit_summary } = await request.rechargeApiRequest(
|
|
12
|
+
"get",
|
|
13
|
+
`/customers/${id}/credit_summary`,
|
|
14
|
+
{
|
|
15
|
+
query: { include: options?.include }
|
|
16
|
+
},
|
|
17
|
+
request.getInternalSession(session, "getCreditSummary")
|
|
18
|
+
);
|
|
19
|
+
return credit_summary;
|
|
20
|
+
}
|
|
21
|
+
function setApplyCreditsToNextCharge(session, { recurring }) {
|
|
22
|
+
const id = session.customerId;
|
|
23
|
+
if (!id) {
|
|
24
|
+
throw new Error("Not logged in.");
|
|
25
|
+
}
|
|
26
|
+
const updateOptions = {};
|
|
27
|
+
if (recurring !== void 0) {
|
|
28
|
+
updateOptions.apply_credit_to_next_recurring_charge = recurring;
|
|
29
|
+
}
|
|
30
|
+
return customer.updateCustomer(request.getInternalSession(session, "setApplyCreditsToNextCharge"), updateOptions);
|
|
31
|
+
}
|
|
32
|
+
async function listCreditAccounts(session, query) {
|
|
33
|
+
const customer_id = session.customerId;
|
|
34
|
+
if (!customer_id) {
|
|
35
|
+
throw new Error("Not logged in.");
|
|
36
|
+
}
|
|
37
|
+
const response = await request.rechargeApiRequest(
|
|
38
|
+
"get",
|
|
39
|
+
"/credit_accounts",
|
|
40
|
+
{
|
|
41
|
+
query: { customer_id, ...query }
|
|
42
|
+
},
|
|
43
|
+
request.getInternalSession(session, "listCreditAccounts")
|
|
44
|
+
);
|
|
45
|
+
return response;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
exports.getCreditSummary = getCreditSummary;
|
|
49
|
+
exports.listCreditAccounts = listCreditAccounts;
|
|
50
|
+
exports.setApplyCreditsToNextCharge = setApplyCreditsToNextCharge;
|
|
51
|
+
//# sourceMappingURL=credit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credit.js","sources":["../../../src/api/credit.ts"],"sourcesContent":["import {\n ApplyCreditOptions,\n CreditAccountListParams,\n CreditAccountsResponse,\n Customer,\n CustomerCreditSummary,\n GetCreditSummaryOptions,\n Session,\n UpdateCustomerRequest,\n} from '../types';\nimport { getInternalSession, rechargeApiRequest } from '../utils/request';\nimport { updateCustomer } from './customer';\n\nexport async function getCreditSummary(\n session: Session,\n options?: GetCreditSummaryOptions\n): Promise<CustomerCreditSummary> {\n const id = session.customerId;\n if (!id) {\n throw new Error('Not logged in.');\n }\n const { credit_summary } = await rechargeApiRequest<{ credit_summary: CustomerCreditSummary }>(\n 'get',\n `/customers/${id}/credit_summary`,\n {\n query: { include: options?.include },\n },\n getInternalSession(session, 'getCreditSummary')\n );\n return credit_summary;\n}\n\nexport function setApplyCreditsToNextCharge(session: Session, { recurring }: ApplyCreditOptions): Promise<Customer> {\n const id = session.customerId;\n if (!id) {\n throw new Error('Not logged in.');\n }\n const updateOptions: UpdateCustomerRequest = {};\n if (recurring !== undefined) {\n updateOptions.apply_credit_to_next_recurring_charge = recurring;\n }\n return updateCustomer(getInternalSession(session, 'setApplyCreditsToNextCharge'), updateOptions);\n}\n\nexport async function listCreditAccounts(\n session: Session,\n query?: CreditAccountListParams\n): Promise<CreditAccountsResponse> {\n const customer_id = session.customerId;\n if (!customer_id) {\n throw new Error('Not logged in.');\n }\n const response = await rechargeApiRequest<CreditAccountsResponse>(\n 'get',\n '/credit_accounts',\n {\n query: { customer_id, ...query },\n },\n getInternalSession(session, 'listCreditAccounts')\n );\n return response;\n}\n"],"names":["rechargeApiRequest","getInternalSession","updateCustomer"],"mappings":";;;;;AAasB,eAAA,gBAAA,CACpB,SACA,OACgC,EAAA;AAChC,EAAA,MAAM,KAAK,OAAQ,CAAA,UAAA,CAAA;AACnB,EAAA,IAAI,CAAC,EAAI,EAAA;AACP,IAAM,MAAA,IAAI,MAAM,gBAAgB,CAAA,CAAA;AAAA,GAClC;AACA,EAAM,MAAA,EAAE,cAAe,EAAA,GAAI,MAAMA,0BAAA;AAAA,IAC/B,KAAA;AAAA,IACA,cAAc,EAAE,CAAA,eAAA,CAAA;AAAA,IAChB;AAAA,MACE,KAAO,EAAA,EAAE,OAAS,EAAA,OAAA,EAAS,OAAQ,EAAA;AAAA,KACrC;AAAA,IACAC,0BAAA,CAAmB,SAAS,kBAAkB,CAAA;AAAA,GAChD,CAAA;AACA,EAAO,OAAA,cAAA,CAAA;AACT,CAAA;AAEO,SAAS,2BAA4B,CAAA,OAAA,EAAkB,EAAE,SAAA,EAAoD,EAAA;AAClH,EAAA,MAAM,KAAK,OAAQ,CAAA,UAAA,CAAA;AACnB,EAAA,IAAI,CAAC,EAAI,EAAA;AACP,IAAM,MAAA,IAAI,MAAM,gBAAgB,CAAA,CAAA;AAAA,GAClC;AACA,EAAA,MAAM,gBAAuC,EAAC,CAAA;AAC9C,EAAA,IAAI,cAAc,KAAW,CAAA,EAAA;AAC3B,IAAA,aAAA,CAAc,qCAAwC,GAAA,SAAA,CAAA;AAAA,GACxD;AACA,EAAA,OAAOC,uBAAe,CAAAD,0BAAA,CAAmB,OAAS,EAAA,6BAA6B,GAAG,aAAa,CAAA,CAAA;AACjG,CAAA;AAEsB,eAAA,kBAAA,CACpB,SACA,KACiC,EAAA;AACjC,EAAA,MAAM,cAAc,OAAQ,CAAA,UAAA,CAAA;AAC5B,EAAA,IAAI,CAAC,WAAa,EAAA;AAChB,IAAM,MAAA,IAAI,MAAM,gBAAgB,CAAA,CAAA;AAAA,GAClC;AACA,EAAA,MAAM,WAAW,MAAMD,0BAAA;AAAA,IACrB,KAAA;AAAA,IACA,kBAAA;AAAA,IACA;AAAA,MACE,KAAO,EAAA,EAAE,WAAa,EAAA,GAAG,KAAM,EAAA;AAAA,KACjC;AAAA,IACAC,0BAAA,CAAmB,SAAS,oBAAoB,CAAA;AAAA,GAClD,CAAA;AACA,EAAO,OAAA,QAAA,CAAA;AACT;;;;;;"}
|
package/dist/cjs/api/customer.js
CHANGED
|
@@ -97,24 +97,8 @@ async function sendCustomerNotification(session, notification, options) {
|
|
|
97
97
|
request.getInternalSession(session, "sendCustomerNotification")
|
|
98
98
|
);
|
|
99
99
|
}
|
|
100
|
-
async function getCreditSummary(session, options) {
|
|
101
|
-
const id = session.customerId;
|
|
102
|
-
if (!id) {
|
|
103
|
-
throw new Error("Not logged in.");
|
|
104
|
-
}
|
|
105
|
-
const { credit_summary } = await request.rechargeApiRequest(
|
|
106
|
-
"get",
|
|
107
|
-
`/customers/${id}/credit_summary`,
|
|
108
|
-
{
|
|
109
|
-
query: { include: options?.include }
|
|
110
|
-
},
|
|
111
|
-
request.getInternalSession(session, "getCreditSummary")
|
|
112
|
-
);
|
|
113
|
-
return credit_summary;
|
|
114
|
-
}
|
|
115
100
|
|
|
116
101
|
exports.getActiveChurnLandingPageURL = getActiveChurnLandingPageURL;
|
|
117
|
-
exports.getCreditSummary = getCreditSummary;
|
|
118
102
|
exports.getCustomer = getCustomer;
|
|
119
103
|
exports.getCustomerPortalAccess = getCustomerPortalAccess;
|
|
120
104
|
exports.getDeliverySchedule = getDeliverySchedule;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customer.js","sources":["../../../src/api/customer.ts"],"sourcesContent":["import {\n Customer,\n CustomerCreditSummary,\n CustomerDeliveryScheduleParams,\n CustomerDeliveryScheduleResponse,\n CustomerNotification,\n CustomerNotificationOptions,\n CustomerNotificationTemplate,\n CustomerNotificationType,\n CustomerPortalAccessResponse,\n Delivery,\n GetCreditSummaryOptions,\n GetCustomerOptions,\n UpdateCustomerRequest,\n Session,\n} from '../types';\nimport { getInternalSession, rechargeApiRequest } from '../utils/request';\n\nexport async function getCustomer(session: Session, options?: GetCustomerOptions): Promise<Customer> {\n const id = session.customerId;\n if (!id) {\n throw new Error('Not logged in.');\n }\n const { customer } = await rechargeApiRequest<{ customer: Customer }>(\n 'get',\n `/customers`,\n {\n id,\n query: { include: options?.include },\n },\n getInternalSession(session, 'getCustomer')\n );\n return customer;\n}\n\nexport async function updateCustomer(session: Session, updateRequest: UpdateCustomerRequest): Promise<Customer> {\n const id = session.customerId;\n if (!id) {\n throw new Error('Not logged in.');\n }\n const { customer } = await rechargeApiRequest<{ customer: Customer }>(\n 'put',\n `/customers`,\n { id, data: updateRequest },\n getInternalSession(session, 'updateCustomer')\n );\n return customer;\n}\n\nexport async function getDeliverySchedule(\n session: Session,\n query?: CustomerDeliveryScheduleParams\n): Promise<Delivery[]> {\n const id = session.customerId;\n if (!id) {\n throw new Error('Not logged in.');\n }\n const { deliveries } = await rechargeApiRequest<CustomerDeliveryScheduleResponse>(\n 'get',\n `/customers/${id}/delivery_schedule`,\n { query },\n getInternalSession(session, 'getDeliverySchedule')\n );\n return deliveries;\n}\n\nexport async function getCustomerPortalAccess(session: Session): Promise<CustomerPortalAccessResponse> {\n return rechargeApiRequest<CustomerPortalAccessResponse>(\n 'get',\n '/portal_access',\n {},\n getInternalSession(session, 'getCustomerPortalAccess')\n );\n}\n\nexport async function getActiveChurnLandingPageURL(\n session: Session,\n subscriptionId: string | number,\n redirectURL: string\n): Promise<string> {\n const { base_url, customer_hash, temp_token } = await getCustomerPortalAccess(\n getInternalSession(session, 'getActiveChurnLandingPageURL')\n );\n return `${base_url.replace(\n 'portal',\n 'pages'\n )}${customer_hash}/subscriptions/${subscriptionId}/cancel?token=${temp_token}&subscription=${subscriptionId}&redirect_to=${redirectURL}`;\n}\n\nexport async function getGiftRedemptionLandingPageURL(\n session: Session,\n giftId: string | number,\n redirectURL: string\n): Promise<string> {\n const { base_url, customer_hash, temp_token } = await getCustomerPortalAccess(\n getInternalSession(session, 'getGiftRedemptionLandingPageURL')\n );\n return `${base_url.replace(\n 'portal',\n 'pages'\n )}${customer_hash}/gifts/${giftId}?token=${temp_token}&redirect_to=${redirectURL}`;\n}\n\nconst customerNotificationMap: Record<\n CustomerNotification,\n { type: CustomerNotificationType; template_type: CustomerNotificationTemplate }\n> = {\n SHOPIFY_UPDATE_PAYMENT_INFO: {\n type: 'email',\n template_type: 'shopify_update_payment_information',\n },\n};\n\nexport async function sendCustomerNotification<T extends CustomerNotification>(\n session: Session,\n notification: CustomerNotification,\n options?: CustomerNotificationOptions<T>\n): Promise<void> {\n const customerId = session.customerId;\n if (!customerId) {\n throw new Error('Not logged in.');\n }\n const data = customerNotificationMap[notification];\n if (!data) {\n throw new Error('Notification not supported.');\n }\n return rechargeApiRequest<void>(\n 'post',\n `/customers/${customerId}/notifications`,\n {\n data: {\n ...data,\n template_vars: options,\n },\n },\n getInternalSession(session, 'sendCustomerNotification')\n );\n}\n\nexport async function getCreditSummary(\n session: Session,\n options?: GetCreditSummaryOptions\n): Promise<CustomerCreditSummary> {\n const id = session.customerId;\n if (!id) {\n throw new Error('Not logged in.');\n }\n const { credit_summary } = await rechargeApiRequest<{ credit_summary: CustomerCreditSummary }>(\n 'get',\n `/customers/${id}/credit_summary`,\n {\n query: { include: options?.include },\n },\n getInternalSession(session, 'getCreditSummary')\n );\n return credit_summary;\n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M,uBAGF,GAAA;AAAA,EACF,2BAA6B,EAAA;AAAA,IAC3B,IAAM,EAAA,OAAA;AAAA,IACN,aAAe,EAAA,oCAAA;AAAA,GACjB;AACF,CAAA,CAAA;AAEsB,eAAA,wBAAA,CACpB,OACA,EAAA,YAAA,EACA,OACe,EAAA;AACf,EAAA,MAAM,aAAa,OAAQ,CAAA,UAAA,CAAA;AAC3B,EAAA,IAAI,CAAC,UAAY,EAAA;AACf,IAAM,MAAA,IAAI,MAAM,gBAAgB,CAAA,CAAA;AAAA,GAClC;AACA,EAAM,MAAA,IAAA,GAAO,wBAAwB,YAAY,CAAA,CAAA;AACjD,EAAA,IAAI,CAAC,IAAM,EAAA;AACT,IAAM,MAAA,IAAI,MAAM,6BAA6B,CAAA,CAAA;AAAA,GAC/C;AACA,EAAO,OAAAD,0BAAA;AAAA,IACL,MAAA;AAAA,IACA,cAAc,UAAU,CAAA,cAAA,CAAA;AAAA,IACxB;AAAA,MACE,IAAM,EAAA;AAAA,QACJ,GAAG,IAAA;AAAA,QACH,aAAe,EAAA,OAAA;AAAA,OACjB;AAAA,KACF;AAAA,IACAC,0BAAA,CAAmB,SAAS,0BAA0B,CAAA;AAAA,GACxD,CAAA;AACF
|
|
1
|
+
{"version":3,"file":"customer.js","sources":["../../../src/api/customer.ts"],"sourcesContent":["import {\n Customer,\n CustomerCreditSummary,\n CustomerDeliveryScheduleParams,\n CustomerDeliveryScheduleResponse,\n CustomerNotification,\n CustomerNotificationOptions,\n CustomerNotificationTemplate,\n CustomerNotificationType,\n CustomerPortalAccessResponse,\n Delivery,\n GetCreditSummaryOptions,\n GetCustomerOptions,\n UpdateCustomerRequest,\n Session,\n} from '../types';\nimport { getInternalSession, rechargeApiRequest } from '../utils/request';\n\nexport async function getCustomer(session: Session, options?: GetCustomerOptions): Promise<Customer> {\n const id = session.customerId;\n if (!id) {\n throw new Error('Not logged in.');\n }\n const { customer } = await rechargeApiRequest<{ customer: Customer }>(\n 'get',\n `/customers`,\n {\n id,\n query: { include: options?.include },\n },\n getInternalSession(session, 'getCustomer')\n );\n return customer;\n}\n\nexport async function updateCustomer(session: Session, updateRequest: UpdateCustomerRequest): Promise<Customer> {\n const id = session.customerId;\n if (!id) {\n throw new Error('Not logged in.');\n }\n const { customer } = await rechargeApiRequest<{ customer: Customer }>(\n 'put',\n `/customers`,\n { id, data: updateRequest },\n getInternalSession(session, 'updateCustomer')\n );\n return customer;\n}\n\nexport async function getDeliverySchedule(\n session: Session,\n query?: CustomerDeliveryScheduleParams\n): Promise<Delivery[]> {\n const id = session.customerId;\n if (!id) {\n throw new Error('Not logged in.');\n }\n const { deliveries } = await rechargeApiRequest<CustomerDeliveryScheduleResponse>(\n 'get',\n `/customers/${id}/delivery_schedule`,\n { query },\n getInternalSession(session, 'getDeliverySchedule')\n );\n return deliveries;\n}\n\nexport async function getCustomerPortalAccess(session: Session): Promise<CustomerPortalAccessResponse> {\n return rechargeApiRequest<CustomerPortalAccessResponse>(\n 'get',\n '/portal_access',\n {},\n getInternalSession(session, 'getCustomerPortalAccess')\n );\n}\n\nexport async function getActiveChurnLandingPageURL(\n session: Session,\n subscriptionId: string | number,\n redirectURL: string\n): Promise<string> {\n const { base_url, customer_hash, temp_token } = await getCustomerPortalAccess(\n getInternalSession(session, 'getActiveChurnLandingPageURL')\n );\n return `${base_url.replace(\n 'portal',\n 'pages'\n )}${customer_hash}/subscriptions/${subscriptionId}/cancel?token=${temp_token}&subscription=${subscriptionId}&redirect_to=${redirectURL}`;\n}\n\nexport async function getGiftRedemptionLandingPageURL(\n session: Session,\n giftId: string | number,\n redirectURL: string\n): Promise<string> {\n const { base_url, customer_hash, temp_token } = await getCustomerPortalAccess(\n getInternalSession(session, 'getGiftRedemptionLandingPageURL')\n );\n return `${base_url.replace(\n 'portal',\n 'pages'\n )}${customer_hash}/gifts/${giftId}?token=${temp_token}&redirect_to=${redirectURL}`;\n}\n\nconst customerNotificationMap: Record<\n CustomerNotification,\n { type: CustomerNotificationType; template_type: CustomerNotificationTemplate }\n> = {\n SHOPIFY_UPDATE_PAYMENT_INFO: {\n type: 'email',\n template_type: 'shopify_update_payment_information',\n },\n};\n\nexport async function sendCustomerNotification<T extends CustomerNotification>(\n session: Session,\n notification: CustomerNotification,\n options?: CustomerNotificationOptions<T>\n): Promise<void> {\n const customerId = session.customerId;\n if (!customerId) {\n throw new Error('Not logged in.');\n }\n const data = customerNotificationMap[notification];\n if (!data) {\n throw new Error('Notification not supported.');\n }\n return rechargeApiRequest<void>(\n 'post',\n `/customers/${customerId}/notifications`,\n {\n data: {\n ...data,\n template_vars: options,\n },\n },\n getInternalSession(session, 'sendCustomerNotification')\n );\n}\n\n/** @deprecated Use `getCreditSummary` on credit instead */\nexport async function getCreditSummary(\n session: Session,\n options?: GetCreditSummaryOptions\n): Promise<CustomerCreditSummary> {\n const id = session.customerId;\n if (!id) {\n throw new Error('Not logged in.');\n }\n const { credit_summary } = await rechargeApiRequest<{ credit_summary: CustomerCreditSummary }>(\n 'get',\n `/customers/${id}/credit_summary`,\n {\n query: { include: options?.include },\n },\n getInternalSession(session, 'getCreditSummary')\n );\n return credit_summary;\n}\n"],"names":["rechargeApiRequest","getInternalSession"],"mappings":";;;;AAkBsB,eAAA,WAAA,CAAY,SAAkB,OAAiD,EAAA;AACnG,EAAA,MAAM,KAAK,OAAQ,CAAA,UAAA,CAAA;AACnB,EAAA,IAAI,CAAC,EAAI,EAAA;AACP,IAAM,MAAA,IAAI,MAAM,gBAAgB,CAAA,CAAA;AAAA,GAClC;AACA,EAAM,MAAA,EAAE,QAAS,EAAA,GAAI,MAAMA,0BAAA;AAAA,IACzB,KAAA;AAAA,IACA,CAAA,UAAA,CAAA;AAAA,IACA;AAAA,MACE,EAAA;AAAA,MACA,KAAO,EAAA,EAAE,OAAS,EAAA,OAAA,EAAS,OAAQ,EAAA;AAAA,KACrC;AAAA,IACAC,0BAAA,CAAmB,SAAS,aAAa,CAAA;AAAA,GAC3C,CAAA;AACA,EAAO,OAAA,QAAA,CAAA;A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IACA,cAAc,UAAU,CAAA,cAAA,CAAA;AAAA,IACxB;AAAA,MACE,IAAM,EAAA;AAAA,QACJ,GAAG,IAAA;AAAA,QACH,aAAe,EAAA,OAAA;AAAA,OACjB;AAAA,KACF;AAAA,IACAC,0BAAA,CAAmB,SAAS,0BAA0B,CAAA;AAAA,GACxD,CAAA;AACF;;;;;;;;;;"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -6,6 +6,7 @@ var bundle = require('./api/bundle.js');
|
|
|
6
6
|
var cdn = require('./api/cdn.js');
|
|
7
7
|
var charge = require('./api/charge.js');
|
|
8
8
|
var collection = require('./api/collection.js');
|
|
9
|
+
var credit = require('./api/credit.js');
|
|
9
10
|
var customer = require('./api/customer.js');
|
|
10
11
|
var gift = require('./api/gift.js');
|
|
11
12
|
var membership = require('./api/membership.js');
|
|
@@ -68,8 +69,10 @@ exports.unskipCharge = charge.unskipCharge;
|
|
|
68
69
|
exports.getCollection = collection.getCollection;
|
|
69
70
|
exports.listCollectionProducts = collection.listCollectionProducts;
|
|
70
71
|
exports.listCollections = collection.listCollections;
|
|
72
|
+
exports.getCreditSummary = credit.getCreditSummary;
|
|
73
|
+
exports.listCreditAccounts = credit.listCreditAccounts;
|
|
74
|
+
exports.setApplyCreditsToNextCharge = credit.setApplyCreditsToNextCharge;
|
|
71
75
|
exports.getActiveChurnLandingPageURL = customer.getActiveChurnLandingPageURL;
|
|
72
|
-
exports.getCreditSummary = customer.getCreditSummary;
|
|
73
76
|
exports.getCustomer = customer.getCustomer;
|
|
74
77
|
exports.getCustomerPortalAccess = customer.getCustomerPortalAccess;
|
|
75
78
|
exports.getDeliverySchedule = customer.getDeliverySchedule;
|
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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { rechargeApiRequest, getInternalSession } from '../utils/request.js';
|
|
2
|
+
import { updateCustomer } from './customer.js';
|
|
3
|
+
|
|
4
|
+
async function getCreditSummary(session, options) {
|
|
5
|
+
const id = session.customerId;
|
|
6
|
+
if (!id) {
|
|
7
|
+
throw new Error("Not logged in.");
|
|
8
|
+
}
|
|
9
|
+
const { credit_summary } = await rechargeApiRequest(
|
|
10
|
+
"get",
|
|
11
|
+
`/customers/${id}/credit_summary`,
|
|
12
|
+
{
|
|
13
|
+
query: { include: options?.include }
|
|
14
|
+
},
|
|
15
|
+
getInternalSession(session, "getCreditSummary")
|
|
16
|
+
);
|
|
17
|
+
return credit_summary;
|
|
18
|
+
}
|
|
19
|
+
function setApplyCreditsToNextCharge(session, { recurring }) {
|
|
20
|
+
const id = session.customerId;
|
|
21
|
+
if (!id) {
|
|
22
|
+
throw new Error("Not logged in.");
|
|
23
|
+
}
|
|
24
|
+
const updateOptions = {};
|
|
25
|
+
if (recurring !== void 0) {
|
|
26
|
+
updateOptions.apply_credit_to_next_recurring_charge = recurring;
|
|
27
|
+
}
|
|
28
|
+
return updateCustomer(getInternalSession(session, "setApplyCreditsToNextCharge"), updateOptions);
|
|
29
|
+
}
|
|
30
|
+
async function listCreditAccounts(session, query) {
|
|
31
|
+
const customer_id = session.customerId;
|
|
32
|
+
if (!customer_id) {
|
|
33
|
+
throw new Error("Not logged in.");
|
|
34
|
+
}
|
|
35
|
+
const response = await rechargeApiRequest(
|
|
36
|
+
"get",
|
|
37
|
+
"/credit_accounts",
|
|
38
|
+
{
|
|
39
|
+
query: { customer_id, ...query }
|
|
40
|
+
},
|
|
41
|
+
getInternalSession(session, "listCreditAccounts")
|
|
42
|
+
);
|
|
43
|
+
return response;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export { getCreditSummary, listCreditAccounts, setApplyCreditsToNextCharge };
|
|
47
|
+
//# sourceMappingURL=credit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credit.js","sources":["../../../src/api/credit.ts"],"sourcesContent":["import {\n ApplyCreditOptions,\n CreditAccountListParams,\n CreditAccountsResponse,\n Customer,\n CustomerCreditSummary,\n GetCreditSummaryOptions,\n Session,\n UpdateCustomerRequest,\n} from '../types';\nimport { getInternalSession, rechargeApiRequest } from '../utils/request';\nimport { updateCustomer } from './customer';\n\nexport async function getCreditSummary(\n session: Session,\n options?: GetCreditSummaryOptions\n): Promise<CustomerCreditSummary> {\n const id = session.customerId;\n if (!id) {\n throw new Error('Not logged in.');\n }\n const { credit_summary } = await rechargeApiRequest<{ credit_summary: CustomerCreditSummary }>(\n 'get',\n `/customers/${id}/credit_summary`,\n {\n query: { include: options?.include },\n },\n getInternalSession(session, 'getCreditSummary')\n );\n return credit_summary;\n}\n\nexport function setApplyCreditsToNextCharge(session: Session, { recurring }: ApplyCreditOptions): Promise<Customer> {\n const id = session.customerId;\n if (!id) {\n throw new Error('Not logged in.');\n }\n const updateOptions: UpdateCustomerRequest = {};\n if (recurring !== undefined) {\n updateOptions.apply_credit_to_next_recurring_charge = recurring;\n }\n return updateCustomer(getInternalSession(session, 'setApplyCreditsToNextCharge'), updateOptions);\n}\n\nexport async function listCreditAccounts(\n session: Session,\n query?: CreditAccountListParams\n): Promise<CreditAccountsResponse> {\n const customer_id = session.customerId;\n if (!customer_id) {\n throw new Error('Not logged in.');\n }\n const response = await rechargeApiRequest<CreditAccountsResponse>(\n 'get',\n '/credit_accounts',\n {\n query: { customer_id, ...query },\n },\n getInternalSession(session, 'listCreditAccounts')\n );\n return response;\n}\n"],"names":[],"mappings":";;;AAasB,eAAA,gBAAA,CACpB,SACA,OACgC,EAAA;AAChC,EAAA,MAAM,KAAK,OAAQ,CAAA,UAAA,CAAA;AAC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AAS,oBAAoB,CAAA;AAAA,GAClD,CAAA;AACA,EAAO,OAAA,QAAA,CAAA;AACT;;;;"}
|
package/dist/esm/api/customer.js
CHANGED
|
@@ -95,21 +95,6 @@ async function sendCustomerNotification(session, notification, options) {
|
|
|
95
95
|
getInternalSession(session, "sendCustomerNotification")
|
|
96
96
|
);
|
|
97
97
|
}
|
|
98
|
-
async function getCreditSummary(session, options) {
|
|
99
|
-
const id = session.customerId;
|
|
100
|
-
if (!id) {
|
|
101
|
-
throw new Error("Not logged in.");
|
|
102
|
-
}
|
|
103
|
-
const { credit_summary } = await rechargeApiRequest(
|
|
104
|
-
"get",
|
|
105
|
-
`/customers/${id}/credit_summary`,
|
|
106
|
-
{
|
|
107
|
-
query: { include: options?.include }
|
|
108
|
-
},
|
|
109
|
-
getInternalSession(session, "getCreditSummary")
|
|
110
|
-
);
|
|
111
|
-
return credit_summary;
|
|
112
|
-
}
|
|
113
98
|
|
|
114
|
-
export { getActiveChurnLandingPageURL,
|
|
99
|
+
export { getActiveChurnLandingPageURL, getCustomer, getCustomerPortalAccess, getDeliverySchedule, getGiftRedemptionLandingPageURL, sendCustomerNotification, updateCustomer };
|
|
115
100
|
//# sourceMappingURL=customer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customer.js","sources":["../../../src/api/customer.ts"],"sourcesContent":["import {\n Customer,\n CustomerCreditSummary,\n CustomerDeliveryScheduleParams,\n CustomerDeliveryScheduleResponse,\n CustomerNotification,\n CustomerNotificationOptions,\n CustomerNotificationTemplate,\n CustomerNotificationType,\n CustomerPortalAccessResponse,\n Delivery,\n GetCreditSummaryOptions,\n GetCustomerOptions,\n UpdateCustomerRequest,\n Session,\n} from '../types';\nimport { getInternalSession, rechargeApiRequest } from '../utils/request';\n\nexport async function getCustomer(session: Session, options?: GetCustomerOptions): Promise<Customer> {\n const id = session.customerId;\n if (!id) {\n throw new Error('Not logged in.');\n }\n const { customer } = await rechargeApiRequest<{ customer: Customer }>(\n 'get',\n `/customers`,\n {\n id,\n query: { include: options?.include },\n },\n getInternalSession(session, 'getCustomer')\n );\n return customer;\n}\n\nexport async function updateCustomer(session: Session, updateRequest: UpdateCustomerRequest): Promise<Customer> {\n const id = session.customerId;\n if (!id) {\n throw new Error('Not logged in.');\n }\n const { customer } = await rechargeApiRequest<{ customer: Customer }>(\n 'put',\n `/customers`,\n { id, data: updateRequest },\n getInternalSession(session, 'updateCustomer')\n );\n return customer;\n}\n\nexport async function getDeliverySchedule(\n session: Session,\n query?: CustomerDeliveryScheduleParams\n): Promise<Delivery[]> {\n const id = session.customerId;\n if (!id) {\n throw new Error('Not logged in.');\n }\n const { deliveries } = await rechargeApiRequest<CustomerDeliveryScheduleResponse>(\n 'get',\n `/customers/${id}/delivery_schedule`,\n { query },\n getInternalSession(session, 'getDeliverySchedule')\n );\n return deliveries;\n}\n\nexport async function getCustomerPortalAccess(session: Session): Promise<CustomerPortalAccessResponse> {\n return rechargeApiRequest<CustomerPortalAccessResponse>(\n 'get',\n '/portal_access',\n {},\n getInternalSession(session, 'getCustomerPortalAccess')\n );\n}\n\nexport async function getActiveChurnLandingPageURL(\n session: Session,\n subscriptionId: string | number,\n redirectURL: string\n): Promise<string> {\n const { base_url, customer_hash, temp_token } = await getCustomerPortalAccess(\n getInternalSession(session, 'getActiveChurnLandingPageURL')\n );\n return `${base_url.replace(\n 'portal',\n 'pages'\n )}${customer_hash}/subscriptions/${subscriptionId}/cancel?token=${temp_token}&subscription=${subscriptionId}&redirect_to=${redirectURL}`;\n}\n\nexport async function getGiftRedemptionLandingPageURL(\n session: Session,\n giftId: string | number,\n redirectURL: string\n): Promise<string> {\n const { base_url, customer_hash, temp_token } = await getCustomerPortalAccess(\n getInternalSession(session, 'getGiftRedemptionLandingPageURL')\n );\n return `${base_url.replace(\n 'portal',\n 'pages'\n )}${customer_hash}/gifts/${giftId}?token=${temp_token}&redirect_to=${redirectURL}`;\n}\n\nconst customerNotificationMap: Record<\n CustomerNotification,\n { type: CustomerNotificationType; template_type: CustomerNotificationTemplate }\n> = {\n SHOPIFY_UPDATE_PAYMENT_INFO: {\n type: 'email',\n template_type: 'shopify_update_payment_information',\n },\n};\n\nexport async function sendCustomerNotification<T extends CustomerNotification>(\n session: Session,\n notification: CustomerNotification,\n options?: CustomerNotificationOptions<T>\n): Promise<void> {\n const customerId = session.customerId;\n if (!customerId) {\n throw new Error('Not logged in.');\n }\n const data = customerNotificationMap[notification];\n if (!data) {\n throw new Error('Notification not supported.');\n }\n return rechargeApiRequest<void>(\n 'post',\n `/customers/${customerId}/notifications`,\n {\n data: {\n ...data,\n template_vars: options,\n },\n },\n getInternalSession(session, 'sendCustomerNotification')\n );\n}\n\nexport async function getCreditSummary(\n session: Session,\n options?: GetCreditSummaryOptions\n): Promise<CustomerCreditSummary> {\n const id = session.customerId;\n if (!id) {\n throw new Error('Not logged in.');\n }\n const { credit_summary } = await rechargeApiRequest<{ credit_summary: CustomerCreditSummary }>(\n 'get',\n `/customers/${id}/credit_summary`,\n {\n query: { include: options?.include },\n },\n getInternalSession(session, 'getCreditSummary')\n );\n return credit_summary;\n}\n"],"names":[],"mappings":";;AAkBsB,eAAA,WAAA,CAAY,SAAkB,OAAiD,EAAA;AACnG,EAAA,MAAM,KAAK,OAAQ,CAAA,UAAA,CAAA;AACnB,EAAA,IAAI,CAAC,EAAI,EAAA;AACP,IAAM,MAAA,IAAI,MAAM,gBAAgB,CAAA,CAAA;AAAA,GAClC;AACA,EAAM,MAAA,EAAE,QAAS,EAAA,GAAI,MAAM,kBAAA;AAAA,IACzB,KAAA;AAAA,IACA,CAAA,UAAA,CAAA;AAAA,IACA;AAAA,MACE,EAAA;AAAA,MACA,KAAO,EAAA,EAAE,OAAS,EAAA,OAAA,EAAS,OAAQ,EAAA;AAAA,KACrC;AAAA,IACA,kBAAA,CAAmB,SAAS,aAAa,CAAA;AAAA,GAC3C,CAAA;AACA,EAAO,OAAA,QAAA,CAAA;AACT,CAAA;AAEsB,eAAA,cAAA,CAAe,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;AAAA,MACE,IAAM,EAAA;AAAA,QACJ,GAAG,IAAA;AAAA,QACH,aAAe,EAAA,OAAA;AAAA,OACjB;AAAA,KACF;AAAA,IACA,kBAAA,CAAmB,SAAS,0BAA0B,CAAA;AAAA,GACxD,CAAA;AACF
|
|
1
|
+
{"version":3,"file":"customer.js","sources":["../../../src/api/customer.ts"],"sourcesContent":["import {\n Customer,\n CustomerCreditSummary,\n CustomerDeliveryScheduleParams,\n CustomerDeliveryScheduleResponse,\n CustomerNotification,\n CustomerNotificationOptions,\n CustomerNotificationTemplate,\n CustomerNotificationType,\n CustomerPortalAccessResponse,\n Delivery,\n GetCreditSummaryOptions,\n GetCustomerOptions,\n UpdateCustomerRequest,\n Session,\n} from '../types';\nimport { getInternalSession, rechargeApiRequest } from '../utils/request';\n\nexport async function getCustomer(session: Session, options?: GetCustomerOptions): Promise<Customer> {\n const id = session.customerId;\n if (!id) {\n throw new Error('Not logged in.');\n }\n const { customer } = await rechargeApiRequest<{ customer: Customer }>(\n 'get',\n `/customers`,\n {\n id,\n query: { include: options?.include },\n },\n getInternalSession(session, 'getCustomer')\n );\n return customer;\n}\n\nexport async function updateCustomer(session: Session, updateRequest: UpdateCustomerRequest): Promise<Customer> {\n const id = session.customerId;\n if (!id) {\n throw new Error('Not logged in.');\n }\n const { customer } = await rechargeApiRequest<{ customer: Customer }>(\n 'put',\n `/customers`,\n { id, data: updateRequest },\n getInternalSession(session, 'updateCustomer')\n );\n return customer;\n}\n\nexport async function getDeliverySchedule(\n session: Session,\n query?: CustomerDeliveryScheduleParams\n): Promise<Delivery[]> {\n const id = session.customerId;\n if (!id) {\n throw new Error('Not logged in.');\n }\n const { deliveries } = await rechargeApiRequest<CustomerDeliveryScheduleResponse>(\n 'get',\n `/customers/${id}/delivery_schedule`,\n { query },\n getInternalSession(session, 'getDeliverySchedule')\n );\n return deliveries;\n}\n\nexport async function getCustomerPortalAccess(session: Session): Promise<CustomerPortalAccessResponse> {\n return rechargeApiRequest<CustomerPortalAccessResponse>(\n 'get',\n '/portal_access',\n {},\n getInternalSession(session, 'getCustomerPortalAccess')\n );\n}\n\nexport async function getActiveChurnLandingPageURL(\n session: Session,\n subscriptionId: string | number,\n redirectURL: string\n): Promise<string> {\n const { base_url, customer_hash, temp_token } = await getCustomerPortalAccess(\n getInternalSession(session, 'getActiveChurnLandingPageURL')\n );\n return `${base_url.replace(\n 'portal',\n 'pages'\n )}${customer_hash}/subscriptions/${subscriptionId}/cancel?token=${temp_token}&subscription=${subscriptionId}&redirect_to=${redirectURL}`;\n}\n\nexport async function getGiftRedemptionLandingPageURL(\n session: Session,\n giftId: string | number,\n redirectURL: string\n): Promise<string> {\n const { base_url, customer_hash, temp_token } = await getCustomerPortalAccess(\n getInternalSession(session, 'getGiftRedemptionLandingPageURL')\n );\n return `${base_url.replace(\n 'portal',\n 'pages'\n )}${customer_hash}/gifts/${giftId}?token=${temp_token}&redirect_to=${redirectURL}`;\n}\n\nconst customerNotificationMap: Record<\n CustomerNotification,\n { type: CustomerNotificationType; template_type: CustomerNotificationTemplate }\n> = {\n SHOPIFY_UPDATE_PAYMENT_INFO: {\n type: 'email',\n template_type: 'shopify_update_payment_information',\n },\n};\n\nexport async function sendCustomerNotification<T extends CustomerNotification>(\n session: Session,\n notification: CustomerNotification,\n options?: CustomerNotificationOptions<T>\n): Promise<void> {\n const customerId = session.customerId;\n if (!customerId) {\n throw new Error('Not logged in.');\n }\n const data = customerNotificationMap[notification];\n if (!data) {\n throw new Error('Notification not supported.');\n }\n return rechargeApiRequest<void>(\n 'post',\n `/customers/${customerId}/notifications`,\n {\n data: {\n ...data,\n template_vars: options,\n },\n },\n getInternalSession(session, 'sendCustomerNotification')\n );\n}\n\n/** @deprecated Use `getCreditSummary` on credit instead */\nexport async function getCreditSummary(\n session: Session,\n options?: GetCreditSummaryOptions\n): Promise<CustomerCreditSummary> {\n const id = session.customerId;\n if (!id) {\n throw new Error('Not logged in.');\n }\n const { credit_summary } = await rechargeApiRequest<{ credit_summary: CustomerCreditSummary }>(\n 'get',\n `/customers/${id}/credit_summary`,\n {\n query: { include: options?.include },\n },\n getInternalSession(session, 'getCreditSummary')\n );\n return credit_summary;\n}\n"],"names":[],"mappings":";;AAkBsB,eAAA,WAAA,CAAY,SAAkB,OAAiD,EAAA;AACnG,EAAA,MAAM,KAAK,OAAQ,CAAA,UAAA,CAAA;AACnB,EAAA,IAAI,CAAC,EAAI,EAAA;AACP,IAAM,MAAA,IAAI,MAAM,gBAAgB,CAAA,CAAA;AAAA,GAClC;AACA,EAAM,MAAA,EAAE,QAAS,EAAA,GAAI,MAAM,kBAAA;AAAA,IACzB,KAAA;AAAA,IACA,CAAA,UAAA,CAAA;AAAA,IACA;AAAA,MACE,EAAA;AAAA,MACA,KAAO,EAAA,EAAE,OAAS,EAAA,OAAA,EAAS,OAAQ,EAAA;AAAA,KACrC;AAAA,IACA,kBAAA,CAAmB,SAAS,aAAa,CAAA;AAAA,GAC3C,CAAA;AACA,EAAO,OAAA,QAAA,CAAA;AACT,CAAA;AAEsB,eAAA,cAAA,CAAe,SAAkB,aAAyD,EAAA;AAC9G,EAAA,MAAM,KAAK,OAAQ,CAAA,UAAA,CAAA;AACnB,EAAA,IAAI,CAAC,EAAI,EAAA;AACP,IAAM,MAAA,IAAI,MAAM,gBAAgB,CAAA,CAAA;AAAA,GAClC;AACA,EAAM,MAAA,EAAE,QAAS,EAAA,GAAI,MAAM,kBAAA;AAAA,IACzB,KAAA;AAAA,IACA,CAAA,UAAA,CAAA;AAAA,IACA,EAAE,EAAI,EAAA,IAAA,EAAM,aAAc,EAAA;AAAA,IAC1B,kBAAA,CAAmB,SAAS,gBAAgB,CAAA;AAAA,GAC9C,CAAA;AACA,EAAO,OAAA,QAAA,CAAA;AACT,CAAA;AAEsB,eAAA,mBAAA,CACpB,SACA,KACqB,EAAA;AACrB,EAAA,MAAM,KAAK,OAAQ,CAAA,UAAA,CAAA;AACnB,EAAA,IAAI,CAAC,EAAI,EAAA;AACP,IAAM,MAAA,I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OAAA,EAAA,UAAU,gBAAgB,WAAW,CAAA,CAAA,CAAA;AAClF,CAAA;AAEA,MAAM,uBAGF,GAAA;AAAA,EACF,2BAA6B,EAAA;AAAA,IAC3B,IAAM,EAAA,OAAA;AAAA,IACN,aAAe,EAAA,oCAAA;AAAA,GACjB;AACF,CAAA,CAAA;AAEsB,eAAA,wBAAA,CACpB,OACA,EAAA,YAAA,EACA,OACe,EAAA;AACf,EAAA,MAAM,aAAa,OAAQ,CAAA,UAAA,CAAA;AAC3B,EAAA,IAAI,CAAC,UAAY,EAAA;AACf,IAAM,MAAA,IAAI,MAAM,gBAAgB,CAAA,CAAA;AAAA,GAClC;AACA,EAAM,MAAA,IAAA,GAAO,wBAAwB,YAAY,CAAA,CAAA;AACjD,EAAA,IAAI,CAAC,IAAM,EAAA;AACT,IAAM,MAAA,IAAI,MAAM,6BAA6B,CAAA,CAAA;AAAA,GAC/C;AACA,EAAO,OAAA,kBAAA;AAAA,IACL,MAAA;AAAA,IACA,cAAc,UAAU,CAAA,cAAA,CAAA;AAAA,IACxB;AAAA,MACE,IAAM,EAAA;AAAA,QACJ,GAAG,IAAA;AAAA,QACH,aAAe,EAAA,OAAA;AAAA,OACjB;AAAA,KACF;AAAA,IACA,kBAAA,CAAmB,SAAS,0BAA0B,CAAA;AAAA,GACxD,CAAA;AACF;;;;"}
|
package/dist/esm/index.js
CHANGED
|
@@ -4,7 +4,8 @@ export { createBundleSelection, deleteBundleSelection, getBundleId, getBundleSel
|
|
|
4
4
|
export { getCDNBundleSettings, getCDNProduct, getCDNProductAndSettings, getCDNProducts, getCDNProductsAndSettings, getCDNStoreSettings, getCDNWidgetSettings, resetCDNCache } from './api/cdn.js';
|
|
5
5
|
export { applyDiscountToCharge, getCharge, listCharges, processCharge, removeDiscountsFromCharge, skipCharge, unskipCharge } from './api/charge.js';
|
|
6
6
|
export { getCollection, listCollectionProducts, listCollections } from './api/collection.js';
|
|
7
|
-
export {
|
|
7
|
+
export { getCreditSummary, listCreditAccounts, setApplyCreditsToNextCharge } from './api/credit.js';
|
|
8
|
+
export { getActiveChurnLandingPageURL, getCustomer, getCustomerPortalAccess, getDeliverySchedule, getGiftRedemptionLandingPageURL, sendCustomerNotification, updateCustomer } from './api/customer.js';
|
|
8
9
|
export { getGiftPurchase, listGiftPurchases } from './api/gift.js';
|
|
9
10
|
export { activateMembership, cancelMembership, changeMembership, getMembership, listMemberships } from './api/membership.js';
|
|
10
11
|
export { getMembershipProgram, listMembershipPrograms } from './api/membershipProgram.js';
|
package/dist/esm/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":";;;;;;;;;;;;;;;;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -825,7 +825,7 @@ interface Customer {
|
|
|
825
825
|
subscriptions?: Subscription[];
|
|
826
826
|
};
|
|
827
827
|
}
|
|
828
|
-
interface UpdateCustomerRequest extends Partial<Pick<Customer, 'email' | 'first_name' | 'last_name' | 'external_customer_id'>> {
|
|
828
|
+
interface UpdateCustomerRequest extends Partial<Pick<Customer, 'email' | 'first_name' | 'last_name' | 'external_customer_id' | 'apply_credit_to_next_recurring_charge'>> {
|
|
829
829
|
}
|
|
830
830
|
interface CustomerDeliveryScheduleParams {
|
|
831
831
|
delivery_count_future?: number;
|
|
@@ -887,48 +887,6 @@ interface CustomerPortalAccessResponse {
|
|
|
887
887
|
/** Token for use with customer portal */
|
|
888
888
|
temp_token: string;
|
|
889
889
|
}
|
|
890
|
-
type CreditSummaryIncludes = 'credit_details';
|
|
891
|
-
interface GetCreditSummaryOptions {
|
|
892
|
-
include?: CreditSummaryIncludes[];
|
|
893
|
-
}
|
|
894
|
-
type CreditAccountType = 'reward' | 'manual' | 'gift';
|
|
895
|
-
interface CreditAccount {
|
|
896
|
-
/** id of the credit account */
|
|
897
|
-
id: number;
|
|
898
|
-
/** Customer the credit account is associated with */
|
|
899
|
-
customer_id: number;
|
|
900
|
-
/** Store the credit account is associated with */
|
|
901
|
-
store_id: number;
|
|
902
|
-
/** Current balance of the credit account */
|
|
903
|
-
available_balance: string;
|
|
904
|
-
/** When the credit account was created */
|
|
905
|
-
created_at: IsoDateString;
|
|
906
|
-
/** Currency of the credit account */
|
|
907
|
-
currency_code: string;
|
|
908
|
-
/** When the credit account expires */
|
|
909
|
-
expires_at: IsoDateString | null;
|
|
910
|
-
/** Name of the credit account */
|
|
911
|
-
name: string;
|
|
912
|
-
/** Redemption_code associated with credit account */
|
|
913
|
-
redemption_code: string;
|
|
914
|
-
/** The last time the credit account was updated */
|
|
915
|
-
updated_at: IsoDateString;
|
|
916
|
-
api_client_id: number;
|
|
917
|
-
api_client_restricted: boolean;
|
|
918
|
-
/** Type of credit account */
|
|
919
|
-
type: CreditAccountType;
|
|
920
|
-
}
|
|
921
|
-
interface CustomerCreditSummary {
|
|
922
|
-
/** Unique numeric identifier for the Customer. */
|
|
923
|
-
customer_id: number;
|
|
924
|
-
/** The total balance of the customer’s credit accounts. */
|
|
925
|
-
total_available_balance: string;
|
|
926
|
-
/** The currency of the customer’s credit balance. */
|
|
927
|
-
currency_code: string;
|
|
928
|
-
includes?: {
|
|
929
|
-
credit_details: CreditAccount[];
|
|
930
|
-
};
|
|
931
|
-
}
|
|
932
890
|
|
|
933
891
|
interface ShippingLine {
|
|
934
892
|
/** The code associated with the shipping_line of a Charge. */
|
|
@@ -2091,6 +2049,71 @@ interface CollectionListParams extends ListParams<CollectionsSortBy> {
|
|
|
2091
2049
|
title?: string;
|
|
2092
2050
|
}
|
|
2093
2051
|
|
|
2052
|
+
type CreditSummaryIncludes = 'credit_details';
|
|
2053
|
+
interface GetCreditSummaryOptions {
|
|
2054
|
+
include?: CreditSummaryIncludes[];
|
|
2055
|
+
}
|
|
2056
|
+
type CreditAccountType = 'reward' | 'manual' | 'gift';
|
|
2057
|
+
interface CreditAccount {
|
|
2058
|
+
/** id of the credit account */
|
|
2059
|
+
id: number;
|
|
2060
|
+
/** Customer the credit account is associated with */
|
|
2061
|
+
customer_id: number;
|
|
2062
|
+
/** Store the credit account is associated with */
|
|
2063
|
+
store_id: number;
|
|
2064
|
+
/** Current balance of the credit account */
|
|
2065
|
+
available_balance: string;
|
|
2066
|
+
/** When the credit account was created */
|
|
2067
|
+
created_at: IsoDateString;
|
|
2068
|
+
/** Currency of the credit account */
|
|
2069
|
+
currency_code: string;
|
|
2070
|
+
/** When the credit account expires */
|
|
2071
|
+
expires_at: IsoDateString | null;
|
|
2072
|
+
/** Name of the credit account */
|
|
2073
|
+
name: string;
|
|
2074
|
+
/** Redemption_code associated with credit account */
|
|
2075
|
+
redemption_code: string;
|
|
2076
|
+
/** The last time the credit account was updated */
|
|
2077
|
+
updated_at: IsoDateString;
|
|
2078
|
+
api_client_id: number;
|
|
2079
|
+
api_client_restricted: boolean;
|
|
2080
|
+
/** Type of credit account */
|
|
2081
|
+
type: CreditAccountType;
|
|
2082
|
+
}
|
|
2083
|
+
interface CustomerCreditSummary {
|
|
2084
|
+
/** Unique numeric identifier for the Customer. */
|
|
2085
|
+
customer_id: number;
|
|
2086
|
+
/** The total balance of the customer’s credit accounts. */
|
|
2087
|
+
total_available_balance: string;
|
|
2088
|
+
/** The currency of the customer’s credit balance. */
|
|
2089
|
+
currency_code: string;
|
|
2090
|
+
includes?: {
|
|
2091
|
+
credit_details: CreditAccount[];
|
|
2092
|
+
};
|
|
2093
|
+
}
|
|
2094
|
+
type CreditAccountsSortBy = 'id-desc' | 'id-asc' | 'expires_at-asc' | 'expires_at-desc';
|
|
2095
|
+
type CreditAccountIncludes = 'customer';
|
|
2096
|
+
interface CreditAccountListParams extends ListParams<CreditAccountsSortBy> {
|
|
2097
|
+
/** Filter credit accounts by type. */
|
|
2098
|
+
credit_type?: CreditAccountType;
|
|
2099
|
+
/** Filter credit accounts by id. */
|
|
2100
|
+
ids?: (string | number)[];
|
|
2101
|
+
/** Show credit accounts that expire after the given date. */
|
|
2102
|
+
expires_at_min?: IsoDateString;
|
|
2103
|
+
/** Show credit accounts that expire before the given date. */
|
|
2104
|
+
expires_at_max?: IsoDateString;
|
|
2105
|
+
/** Include related data options */
|
|
2106
|
+
include?: CreditAccountIncludes[];
|
|
2107
|
+
}
|
|
2108
|
+
interface CreditAccountsResponse {
|
|
2109
|
+
next_cursor: null | string;
|
|
2110
|
+
previous_cursor: null | string;
|
|
2111
|
+
credit_accounts: CreditAccount[];
|
|
2112
|
+
}
|
|
2113
|
+
interface ApplyCreditOptions {
|
|
2114
|
+
recurring?: boolean;
|
|
2115
|
+
}
|
|
2116
|
+
|
|
2094
2117
|
/** A gift given to a customer. */
|
|
2095
2118
|
interface GiftPurchase {
|
|
2096
2119
|
/** Unique numeric identifier for the Gift. */
|
|
@@ -2566,6 +2589,10 @@ declare function getCollection(session: Session, id: string | number): Promise<C
|
|
|
2566
2589
|
declare function listCollections(session: Session, query?: CollectionListParams): Promise<CollectionsResponse>;
|
|
2567
2590
|
declare function listCollectionProducts<T extends ProductSearchParams_2020_12 | ProductSearchParams_2022_06>(session: Session, id: string | number, query: T): Promise<ProductListResponse<T>>;
|
|
2568
2591
|
|
|
2592
|
+
declare function getCreditSummary(session: Session, options?: GetCreditSummaryOptions): Promise<CustomerCreditSummary>;
|
|
2593
|
+
declare function setApplyCreditsToNextCharge(session: Session, { recurring }: ApplyCreditOptions): Promise<Customer>;
|
|
2594
|
+
declare function listCreditAccounts(session: Session, query?: CreditAccountListParams): Promise<CreditAccountsResponse>;
|
|
2595
|
+
|
|
2569
2596
|
declare function getCustomer(session: Session, options?: GetCustomerOptions): Promise<Customer>;
|
|
2570
2597
|
declare function updateCustomer(session: Session, updateRequest: UpdateCustomerRequest): Promise<Customer>;
|
|
2571
2598
|
declare function getDeliverySchedule(session: Session, query?: CustomerDeliveryScheduleParams): Promise<Delivery[]>;
|
|
@@ -2573,7 +2600,6 @@ declare function getCustomerPortalAccess(session: Session): Promise<CustomerPort
|
|
|
2573
2600
|
declare function getActiveChurnLandingPageURL(session: Session, subscriptionId: string | number, redirectURL: string): Promise<string>;
|
|
2574
2601
|
declare function getGiftRedemptionLandingPageURL(session: Session, giftId: string | number, redirectURL: string): Promise<string>;
|
|
2575
2602
|
declare function sendCustomerNotification<T extends CustomerNotification>(session: Session, notification: CustomerNotification, options?: CustomerNotificationOptions<T>): Promise<void>;
|
|
2576
|
-
declare function getCreditSummary(session: Session, options?: GetCreditSummaryOptions): Promise<CustomerCreditSummary>;
|
|
2577
2603
|
|
|
2578
2604
|
declare function listGiftPurchases(session: Session, options?: GiftPurchasesParams): Promise<GiftPurchasesResponse>;
|
|
2579
2605
|
declare function getGiftPurchase(session: Session, id: number): Promise<GiftPurchase>;
|
|
@@ -2698,4 +2724,4 @@ declare const api: {
|
|
|
2698
2724
|
};
|
|
2699
2725
|
declare function initRecharge(opt?: InitOptions): void;
|
|
2700
2726
|
|
|
2701
|
-
export { type ActivateMembershipRequest, type AddToCartCallbackSettings, type AddonSettings, type Address, type AddressIncludes, type AddressListParams, type AddressListResponse, type AddressResponse, type AddressSortBy, type AnalyticsData, type AssociatedAddress, type BasicSubscriptionParams, type BooleanLike, type BooleanNumbers, type BooleanString, type BooleanStringNumbers, type BundleAppProxy, type BundlePriceRule, type BundleProduct, type BundleProductLayoutSettings, type BundlePurchaseItem, type BundlePurchaseItemParams, type BundleSelection, type BundleSelectionAppProxy, type BundleSelectionItem, type BundleSelectionItemRequiredCreateProps, type BundleSelectionListParams, type BundleSelectionsResponse, type BundleSelectionsSortBy, type BundleTemplateSettings, type BundleTemplateType, type BundleTranslations, type BundleVariant, type BundleVariantOptionSource, type BundleVariantRange, type BundleVariantSelectionDefault, type CDNBaseWidgetSettings, type CDNBundleSettings, type CDNBundleVariant, type CDNBundleVariantOptionSource, type CDNPlan, type CDNProduct, type CDNProductAndSettings, type CDNProductKeyObject, type CDNProductQuery_2020_12, type CDNProductQuery_2022_06, type CDNProductRaw, type CDNProductResource, type CDNProductResponseType, type CDNProductType, type CDNProductVariant_2022_06, type CDNProduct_2022_06, type CDNProductsAndSettings, type CDNProductsAndSettingsResource, type CDNStoreSettings, type CDNSubscriptionOption, type CDNVariant, type CDNVersion, type CDNWidgetSettings, type CDNWidgetSettingsRaw, type CDNWidgetSettingsResource, type CRUDRequestOptions, type CancelMembershipRequest, type CancelSubscriptionRequest, type ChangeMembershipRequest, type ChannelSettings, type Charge, type ChargeIncludes, type ChargeListParams, type ChargeListResponse, type ChargeResponse, type ChargeSortBy, type ChargeStatus, type Collection, type CollectionListParams, type CollectionTypes, type CollectionsResponse, type CollectionsSortBy, type ColorString, type CreateAddressRequest, type CreateBundleSelectionRequest, type CreateMetafieldRequest, type CreateOnetimeRequest, type CreatePaymentMethodRequest, type CreateRecipientAddress, type CreateSubscriptionRequest, type CreditAccount, type CreditAccountType, type CreditSummaryIncludes, type CrossSellsSettings, type Customer, type CustomerCreditSummary, type CustomerDeliveryScheduleParams, type CustomerDeliveryScheduleResponse, type CustomerIncludes, type CustomerNotification, type CustomerNotificationOptions, type CustomerNotificationTemplate, type CustomerNotificationType, type CustomerPortalAccessResponse, type Delivery, type DeliveryLineItem, type DeliveryOrder, type DeliveryPaymentMethod, type Discount, type DiscountType, type DynamicBundleItemAppProxy, type DynamicBundlePropertiesAppProxy, type ExternalAttributeSchema, type ExternalId, type ExternalTransactionId, type FirstOption, type GetAddressOptions, type GetChargeOptions, type GetCreditSummaryOptions, type GetCustomerOptions, type GetMembershipProgramOptions, type GetPaymentMethodOptions, type GetRequestOptions, type GetSubscriptionOptions, type GiftPurchase, type GiftPurchasesParams, type GiftPurchasesResponse, type HTMLString, type InitOptions, type InternalSession, type IntervalUnit, type IsoDateString, type LineItem, type ListParams, type LoginResponse, type Membership, type MembershipBenefit, type MembershipIncludes, type MembershipListParams, type MembershipListResponse, type MembershipProgram, type MembershipProgramIncludes, type MembershipProgramListParams, type MembershipProgramListResponse, type MembershipProgramResponse, type MembershipProgramSortBy, type MembershipProgramStatus, type MembershipResponse, type MembershipStatus, type MembershipsSortBy, type MergeAddressesRequest, type Metafield, type MetafieldOptionalCreateProps, type MetafieldOwnerResource, type MetafieldRequiredCreateProps, type Method, type Modifier, type MultiStepSettings, type OnePageSettings, type Onetime, type OnetimeListParams, type OnetimeOptionalCreateProps, type OnetimeRequiredCreateProps, type OnetimesResponse, type OnetimesSortBy, type Order, type OrderIncludes, type OrderListParams, type OrderSortBy, type OrderStatus, type OrderType, type OrdersResponse, type PasswordlessCodeResponse, type PasswordlessOptions, type PasswordlessValidateResponse, type PaymentDetails, type PaymentMethod, type PaymentMethodIncludes, type PaymentMethodListParams, type PaymentMethodOptionalCreateProps, type PaymentMethodRequiredCreateProps, type PaymentMethodSortBy, type PaymentMethodStatus, type PaymentMethodsResponse, type PaymentType, type Plan, type PlanListParams, type PlanSortBy, type PlanType, type PlansResponse, type ProcessorName, type ProductImage, type ProductInclude, type ProductListResponse, type ProductOption, type ProductSearchParams_2020_12, type ProductSearchParams_2022_06, type ProductSearchResponse_2020_12, type ProductSearchResponse_2022_06, type ProductSearchType, type ProductSource, type ProductValueOption, type ProductVariant_2020_12, type ProductVariant_2022_06, type Product_2020_12, type Product_2022_06, type Property, type PublishStatus, type Request, type RequestHeaders, type RequestOptions, type SellingPlan, type SellingPlanGroup, type Session, type ShippingCountriesOptions, type ShippingCountriesResponse, type ShippingCountry, type ShippingLine, type ShippingProvince, type ShopifyUpdatePaymentInfoOptions, type SkipChargeParams, type SkipFutureChargeAddressRequest, type SkipFutureChargeAddressResponse, type SortBy, type SortField, type SortKeys, type StepSettings, type StepSettingsCommon, type StepSettingsTypes, type StorefrontEnvironment, type StorefrontOptions, type StorefrontPurchaseOption, type SubType, type Subscription, type SubscriptionIncludes, type SubscriptionListParams, type SubscriptionOption, type SubscriptionOptionalCreateProps, type SubscriptionPreferences, type SubscriptionRequiredCreateProps, type SubscriptionSortBy, type SubscriptionStatus, type Subscription_2021_01, type SubscriptionsResponse, type TaxLine, type Translations, type UpdateAddressRequest, type UpdateBundlePurchaseItem, type UpdateBundleSelectionRequest, type UpdateCustomerRequest, type UpdateMetafieldRequest, type UpdateOnetimeRequest, type UpdatePaymentMethodRequest, type UpdateSubscriptionParams, type UpdateSubscriptionRequest, type UpdateSubscriptionsParams, type UpdateSubscriptionsRequest, type VariantSelector, type VariantSelectorStepSetting, type WidgetIconColor, type WidgetTemplateType, type WidgetVisibility, activateMembership, activateSubscription, api, applyDiscountToAddress, applyDiscountToCharge, cancelMembership, cancelSubscription, changeMembership, createAddress, createBundleSelection, createMetafield, createOnetime, createPaymentMethod, createSubscription, createSubscriptions, deleteAddress, deleteBundleSelection, deleteMetafield, deleteOnetime, getActiveChurnLandingPageURL, getAddress, getBundleId, getBundleSelection, getCDNBundleSettings, getCDNProduct, getCDNProductAndSettings, getCDNProducts, getCDNProductsAndSettings, getCDNStoreSettings, getCDNWidgetSettings, getCharge, getCollection, getCreditSummary, getCustomer, getCustomerPortalAccess, getDeliverySchedule, getDynamicBundleItems, getGiftPurchase, getGiftRedemptionLandingPageURL, getMembership, getMembershipProgram, getOnetime, getOrder, getPaymentMethod, getPlan, getShippingCountries, getSubscription, initRecharge, type intervalUnit, listAddresses, listBundleSelections, listCharges, listCollectionProducts, listCollections, listGiftPurchases, listMembershipPrograms, listMemberships, listOnetimes, listOrders, listPaymentMethods, listPlans, listSubscriptions, loginCustomerPortal, loginShopifyApi, loginShopifyAppProxy, loginWithShopifyCustomerAccount, loginWithShopifyStorefront, type membershipIncludes, mergeAddresses, processCharge, productSearch, removeDiscountsFromAddress, removeDiscountsFromCharge, resetCDNCache, sendCustomerNotification, sendPasswordlessCode, sendPasswordlessCodeAppProxy, skipCharge, skipFutureCharge, skipGiftSubscriptionCharge, skipSubscriptionCharge, unskipCharge, updateAddress, updateBundle, updateBundleSelection, updateCustomer, updateMetafield, updateOnetime, updatePaymentMethod, updateSubscription, updateSubscriptionAddress, updateSubscriptionChargeDate, updateSubscriptions, validateBundle, validateDynamicBundle, validatePasswordlessCode, validatePasswordlessCodeAppProxy };
|
|
2727
|
+
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 BundlePriceRule, type BundleProduct, type BundleProductLayoutSettings, type BundlePurchaseItem, type BundlePurchaseItemParams, type BundleSelection, type BundleSelectionAppProxy, type BundleSelectionItem, type BundleSelectionItemRequiredCreateProps, type BundleSelectionListParams, type BundleSelectionsResponse, type BundleSelectionsSortBy, type BundleTemplateSettings, type BundleTemplateType, type BundleTranslations, type BundleVariant, type BundleVariantOptionSource, type BundleVariantRange, type BundleVariantSelectionDefault, type CDNBaseWidgetSettings, type CDNBundleSettings, type CDNBundleVariant, type CDNBundleVariantOptionSource, type CDNPlan, type CDNProduct, type CDNProductAndSettings, type CDNProductKeyObject, type CDNProductQuery_2020_12, type CDNProductQuery_2022_06, type CDNProductRaw, type CDNProductResource, type CDNProductResponseType, type CDNProductType, type CDNProductVariant_2022_06, type CDNProduct_2022_06, type CDNProductsAndSettings, type CDNProductsAndSettingsResource, type CDNStoreSettings, type CDNSubscriptionOption, type CDNVariant, type CDNVersion, type CDNWidgetSettings, type CDNWidgetSettingsRaw, type CDNWidgetSettingsResource, type CRUDRequestOptions, type CancelMembershipRequest, type CancelSubscriptionRequest, type ChangeMembershipRequest, type ChannelSettings, type Charge, type ChargeIncludes, type ChargeListParams, type ChargeListResponse, type ChargeResponse, type ChargeSortBy, type ChargeStatus, type Collection, type CollectionListParams, type CollectionTypes, type CollectionsResponse, type CollectionsSortBy, type ColorString, type CreateAddressRequest, type CreateBundleSelectionRequest, type CreateMetafieldRequest, type CreateOnetimeRequest, type CreatePaymentMethodRequest, type CreateRecipientAddress, type CreateSubscriptionRequest, type CreditAccount, type 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 CustomerPortalAccessResponse, type Delivery, type DeliveryLineItem, type DeliveryOrder, type DeliveryPaymentMethod, type Discount, type DiscountType, type DynamicBundleItemAppProxy, type DynamicBundlePropertiesAppProxy, type ExternalAttributeSchema, type ExternalId, type ExternalTransactionId, type FirstOption, type GetAddressOptions, type GetChargeOptions, type GetCreditSummaryOptions, type GetCustomerOptions, type GetMembershipProgramOptions, type GetPaymentMethodOptions, type GetRequestOptions, type GetSubscriptionOptions, type GiftPurchase, type GiftPurchasesParams, type GiftPurchasesResponse, type HTMLString, type InitOptions, type InternalSession, type IntervalUnit, type IsoDateString, type LineItem, type ListParams, type LoginResponse, type Membership, type MembershipBenefit, type MembershipIncludes, type MembershipListParams, type MembershipListResponse, type MembershipProgram, type MembershipProgramIncludes, type MembershipProgramListParams, type MembershipProgramListResponse, type MembershipProgramResponse, type MembershipProgramSortBy, type MembershipProgramStatus, type MembershipResponse, type MembershipStatus, type MembershipsSortBy, type MergeAddressesRequest, type Metafield, type MetafieldOptionalCreateProps, type MetafieldOwnerResource, type MetafieldRequiredCreateProps, type Method, type Modifier, type MultiStepSettings, type OnePageSettings, type Onetime, type OnetimeListParams, type OnetimeOptionalCreateProps, type OnetimeRequiredCreateProps, type OnetimesResponse, type OnetimesSortBy, type Order, type OrderIncludes, type OrderListParams, type OrderSortBy, type OrderStatus, type OrderType, type OrdersResponse, type PasswordlessCodeResponse, type PasswordlessOptions, type PasswordlessValidateResponse, type PaymentDetails, type PaymentMethod, type PaymentMethodIncludes, type PaymentMethodListParams, type PaymentMethodOptionalCreateProps, type PaymentMethodRequiredCreateProps, type PaymentMethodSortBy, type PaymentMethodStatus, type PaymentMethodsResponse, type PaymentType, type Plan, type PlanListParams, type PlanSortBy, type PlanType, type PlansResponse, type ProcessorName, type ProductImage, type ProductInclude, type ProductListResponse, type ProductOption, type ProductSearchParams_2020_12, type ProductSearchParams_2022_06, type ProductSearchResponse_2020_12, type ProductSearchResponse_2022_06, type ProductSearchType, type ProductSource, type ProductValueOption, type ProductVariant_2020_12, type ProductVariant_2022_06, type Product_2020_12, type Product_2022_06, type Property, type PublishStatus, type Request, type RequestHeaders, type RequestOptions, type SellingPlan, type SellingPlanGroup, type Session, type ShippingCountriesOptions, type ShippingCountriesResponse, type ShippingCountry, type ShippingLine, type ShippingProvince, type ShopifyUpdatePaymentInfoOptions, type SkipChargeParams, type SkipFutureChargeAddressRequest, type SkipFutureChargeAddressResponse, type SortBy, type SortField, type SortKeys, type StepSettings, type StepSettingsCommon, type StepSettingsTypes, type StorefrontEnvironment, type StorefrontOptions, type StorefrontPurchaseOption, type SubType, type Subscription, type SubscriptionIncludes, type SubscriptionListParams, type SubscriptionOption, type SubscriptionOptionalCreateProps, type SubscriptionPreferences, type SubscriptionRequiredCreateProps, type SubscriptionSortBy, type SubscriptionStatus, type Subscription_2021_01, type SubscriptionsResponse, type TaxLine, type Translations, type UpdateAddressRequest, type UpdateBundlePurchaseItem, type UpdateBundleSelectionRequest, type UpdateCustomerRequest, type UpdateMetafieldRequest, type UpdateOnetimeRequest, type UpdatePaymentMethodRequest, type UpdateSubscriptionParams, type UpdateSubscriptionRequest, type UpdateSubscriptionsParams, type UpdateSubscriptionsRequest, type VariantSelector, type VariantSelectorStepSetting, type WidgetIconColor, type WidgetTemplateType, type WidgetVisibility, activateMembership, activateSubscription, api, applyDiscountToAddress, applyDiscountToCharge, cancelMembership, cancelSubscription, changeMembership, createAddress, createBundleSelection, createMetafield, createOnetime, createPaymentMethod, createSubscription, createSubscriptions, deleteAddress, deleteBundleSelection, deleteMetafield, deleteOnetime, getActiveChurnLandingPageURL, getAddress, getBundleId, getBundleSelection, getCDNBundleSettings, getCDNProduct, getCDNProductAndSettings, getCDNProducts, getCDNProductsAndSettings, getCDNStoreSettings, getCDNWidgetSettings, getCharge, getCollection, getCreditSummary, getCustomer, getCustomerPortalAccess, getDeliverySchedule, getDynamicBundleItems, getGiftPurchase, getGiftRedemptionLandingPageURL, getMembership, getMembershipProgram, getOnetime, getOrder, getPaymentMethod, getPlan, getShippingCountries, getSubscription, initRecharge, type intervalUnit, listAddresses, listBundleSelections, listCharges, listCollectionProducts, listCollections, 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, validateDynamicBundle, validatePasswordlessCode, validatePasswordlessCodeAppProxy };
|