@rechargeapps/storefront-client 1.12.0 → 1.14.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.
@@ -66,8 +66,14 @@ async function getDeliverySchedule(session, query) {
66
66
  return deliveries;
67
67
  }
68
68
  async function getCustomerPortalAccess(session) {
69
- const access = await request.rechargeApiRequest("get", "/portal_access", {}, session);
70
- return access;
69
+ return request.rechargeApiRequest("get", "/portal_access", {}, session);
70
+ }
71
+ async function getActiveChurnLandingPageURL(session, subscriptionId, redirectURL) {
72
+ const { base_url, customer_hash, temp_token } = await getCustomerPortalAccess(session);
73
+ return `${base_url.replace(
74
+ "portal",
75
+ "pages"
76
+ )}${customer_hash}/subscriptions/${subscriptionId}/cancel?token=${temp_token}&subscription=${subscriptionId}&redirect_to=${redirectURL}`;
71
77
  }
72
78
  const customerNotificationMap = {
73
79
  SHOPIFY_UPDATE_PAYMENT_INFO: {
@@ -95,7 +101,24 @@ async function sendCustomerNotification(session, notification, options) {
95
101
  session
96
102
  );
97
103
  }
104
+ async function getCreditSummary(session, options) {
105
+ const id = session.customerId;
106
+ if (!id) {
107
+ throw new Error("Not logged in.");
108
+ }
109
+ const { credit_summary } = await request.rechargeApiRequest(
110
+ "get",
111
+ `/customers/${id}/credit_summary`,
112
+ {
113
+ query: { include: options == null ? void 0 : options.include }
114
+ },
115
+ session
116
+ );
117
+ return credit_summary;
118
+ }
98
119
 
120
+ exports.getActiveChurnLandingPageURL = getActiveChurnLandingPageURL;
121
+ exports.getCreditSummary = getCreditSummary;
99
122
  exports.getCustomer = getCustomer;
100
123
  exports.getCustomerPortalAccess = getCustomerPortalAccess;
101
124
  exports.getDeliverySchedule = getDeliverySchedule;
@@ -1 +1 @@
1
- {"version":3,"file":"customer.js","sources":["../../../src/api/customer.ts"],"sourcesContent":["import { Session } from '../types/session';\nimport {\n Customer,\n CustomerDeliveryScheduleParams,\n CustomerDeliveryScheduleResponse,\n CustomerNotification,\n CustomerNotificationOptions,\n CustomerNotificationTemplate,\n CustomerNotificationType,\n CustomerPortalAccessResponse,\n Delivery,\n GetCustomerOptions,\n UpdateCustomerRequest,\n} from '../types/customer';\nimport { 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 session\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 session\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 session\n );\n return deliveries;\n}\n\nexport async function getCustomerPortalAccess(session: Session): Promise<CustomerPortalAccessResponse> {\n const access = await rechargeApiRequest<CustomerPortalAccessResponse>('get', '/portal_access', {}, session);\n return access;\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',\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cAAc,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE;AACpD,QAAQ,aAAa,EAAE,OAAO;AAC9B,OAAO,CAAC;AACR,KAAK;AACL,IAAI,OAAO;AACX,GAAG,CAAC;AACJ;;;;;;;;"}
1
+ {"version":3,"file":"customer.js","sources":["../../../src/api/customer.ts"],"sourcesContent":["import { Session } from '../types/session';\nimport {\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} from '../types/customer';\nimport { 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 session\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 session\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 session\n );\n return deliveries;\n}\n\nexport async function getCustomerPortalAccess(session: Session): Promise<CustomerPortalAccessResponse> {\n return rechargeApiRequest<CustomerPortalAccessResponse>('get', '/portal_access', {}, session);\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(session);\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\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 session\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 session\n );\n return credit_summary;\n}\n"],"names":["rechargeApiRequest"],"mappings":";;;;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,UAAU,GAAG,MAAM,CAAC,gBAAgB,CAAC;AACzC,IAAI,iBAAiB,GAAG,MAAM,CAAC,yBAAyB,CAAC;AACzD,IAAI,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC;AACvD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC;AACnD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,oBAAoB,CAAC;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,OAAO;AAC9B,OAAO,CAAC;AACR,KAAK;AACL,IAAI,OAAO;AACX,GAAG,CAAC;AACJ,CAAC;AACM,eAAe,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE;AACzD,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC;AAChC,EAAE,IAAI,CAAC,EAAE,EAAE;AACX,IAAI,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;AACtC,GAAG;AACH,EAAE,MAAM,EAAE,cAAc,EAAE,GAAG,MAAMA,0BAAkB;AACrD,IAAI,KAAK;AACT,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC,eAAe,CAAC;AACrC,IAAI;AACJ,MAAM,KAAK,EAAE,EAAE,OAAO,EAAE,OAAO,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,OAAO,CAAC,OAAO,EAAE;AACpE,KAAK;AACL,IAAI,OAAO;AACX,GAAG,CAAC;AACJ,EAAE,OAAO,cAAc,CAAC;AACxB;;;;;;;;;;"}
@@ -0,0 +1,24 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var request = require('../utils/request.js');
6
+
7
+ async function getShippingCountries(session, options) {
8
+ const response = await request.rechargeApiRequest(
9
+ "get",
10
+ `/shop/shipping_countries`,
11
+ {
12
+ query: options,
13
+ headers: {
14
+ // Currently this is only available on the older api version.
15
+ "X-Recharge-Version": "2021-01"
16
+ }
17
+ },
18
+ session
19
+ );
20
+ return response;
21
+ }
22
+
23
+ exports.getShippingCountries = getShippingCountries;
24
+ //# sourceMappingURL=store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.js","sources":["../../../src/api/store.ts"],"sourcesContent":["import { Session } from '../types/session';\nimport { ShippingCountriesOptions, ShippingCountriesResponse, ShippingCountry } from '../types/store';\nimport { 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 session\n );\n return response;\n}\n"],"names":["rechargeApiRequest"],"mappings":";;;;;;AACO,eAAe,oBAAoB,CAAC,OAAO,EAAE,OAAO,EAAE;AAC7D,EAAE,MAAM,QAAQ,GAAG,MAAMA,0BAAkB;AAC3C,IAAI,KAAK;AACT,IAAI,CAAC,wBAAwB,CAAC;AAC9B,IAAI;AACJ,MAAM,KAAK,EAAE,OAAO;AACpB,MAAM,OAAO,EAAE;AACf;AACA,QAAQ,oBAAoB,EAAE,SAAS;AACvC,OAAO;AACP,KAAK;AACL,IAAI,OAAO;AACX,GAAG,CAAC;AACJ,EAAE,OAAO,QAAQ,CAAC;AAClB;;;;"}
package/dist/cjs/index.js CHANGED
@@ -4,9 +4,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var address = require('./api/address.js');
6
6
  var auth = require('./api/auth.js');
7
- var charge = require('./api/charge.js');
8
- var cdn = require('./api/cdn.js');
9
7
  var bundle = require('./api/bundle.js');
8
+ var cdn = require('./api/cdn.js');
9
+ var charge = require('./api/charge.js');
10
+ var customer = require('./api/customer.js');
10
11
  var gift = require('./api/gift.js');
11
12
  var membership = require('./api/membership.js');
12
13
  var membershipProgram = require('./api/membershipProgram.js');
@@ -16,8 +17,8 @@ var order = require('./api/order.js');
16
17
  var paymentMethod = require('./api/paymentMethod.js');
17
18
  var plan = require('./api/plan.js');
18
19
  var product = require('./api/product.js');
20
+ var store = require('./api/store.js');
19
21
  var subscription = require('./api/subscription.js');
20
- var customer = require('./api/customer.js');
21
22
  var init = require('./utils/init.js');
22
23
 
23
24
 
@@ -38,21 +39,6 @@ exports.sendPasswordlessCode = auth.sendPasswordlessCode;
38
39
  exports.sendPasswordlessCodeAppProxy = auth.sendPasswordlessCodeAppProxy;
39
40
  exports.validatePasswordlessCode = auth.validatePasswordlessCode;
40
41
  exports.validatePasswordlessCodeAppProxy = auth.validatePasswordlessCodeAppProxy;
41
- exports.applyDiscountToCharge = charge.applyDiscountToCharge;
42
- exports.getCharge = charge.getCharge;
43
- exports.listCharges = charge.listCharges;
44
- exports.processCharge = charge.processCharge;
45
- exports.removeDiscountsFromCharge = charge.removeDiscountsFromCharge;
46
- exports.skipCharge = charge.skipCharge;
47
- exports.unskipCharge = charge.unskipCharge;
48
- exports.getCDNBundleSettings = cdn.getCDNBundleSettings;
49
- exports.getCDNProduct = cdn.getCDNProduct;
50
- exports.getCDNProductAndSettings = cdn.getCDNProductAndSettings;
51
- exports.getCDNProducts = cdn.getCDNProducts;
52
- exports.getCDNProductsAndSettings = cdn.getCDNProductsAndSettings;
53
- exports.getCDNStoreSettings = cdn.getCDNStoreSettings;
54
- exports.getCDNWidgetSettings = cdn.getCDNWidgetSettings;
55
- exports.resetCDNCache = cdn.resetCDNCache;
56
42
  exports.createBundleSelection = bundle.createBundleSelection;
57
43
  exports.deleteBundleSelection = bundle.deleteBundleSelection;
58
44
  exports.getBundleId = bundle.getBundleId;
@@ -63,6 +49,28 @@ exports.updateBundle = bundle.updateBundle;
63
49
  exports.updateBundleSelection = bundle.updateBundleSelection;
64
50
  exports.validateBundle = bundle.validateBundle;
65
51
  exports.validateDynamicBundle = bundle.validateDynamicBundle;
52
+ exports.getCDNBundleSettings = cdn.getCDNBundleSettings;
53
+ exports.getCDNProduct = cdn.getCDNProduct;
54
+ exports.getCDNProductAndSettings = cdn.getCDNProductAndSettings;
55
+ exports.getCDNProducts = cdn.getCDNProducts;
56
+ exports.getCDNProductsAndSettings = cdn.getCDNProductsAndSettings;
57
+ exports.getCDNStoreSettings = cdn.getCDNStoreSettings;
58
+ exports.getCDNWidgetSettings = cdn.getCDNWidgetSettings;
59
+ exports.resetCDNCache = cdn.resetCDNCache;
60
+ exports.applyDiscountToCharge = charge.applyDiscountToCharge;
61
+ exports.getCharge = charge.getCharge;
62
+ exports.listCharges = charge.listCharges;
63
+ exports.processCharge = charge.processCharge;
64
+ exports.removeDiscountsFromCharge = charge.removeDiscountsFromCharge;
65
+ exports.skipCharge = charge.skipCharge;
66
+ exports.unskipCharge = charge.unskipCharge;
67
+ exports.getActiveChurnLandingPageURL = customer.getActiveChurnLandingPageURL;
68
+ exports.getCreditSummary = customer.getCreditSummary;
69
+ exports.getCustomer = customer.getCustomer;
70
+ exports.getCustomerPortalAccess = customer.getCustomerPortalAccess;
71
+ exports.getDeliverySchedule = customer.getDeliverySchedule;
72
+ exports.sendCustomerNotification = customer.sendCustomerNotification;
73
+ exports.updateCustomer = customer.updateCustomer;
66
74
  exports.getGiftPurchase = gift.getGiftPurchase;
67
75
  exports.listGiftPurchases = gift.listGiftPurchases;
68
76
  exports.activateMembership = membership.activateMembership;
@@ -89,6 +97,7 @@ exports.updatePaymentMethod = paymentMethod.updatePaymentMethod;
89
97
  exports.getPlan = plan.getPlan;
90
98
  exports.listPlans = plan.listPlans;
91
99
  exports.productSearch = product.productSearch;
100
+ exports.getShippingCountries = store.getShippingCountries;
92
101
  exports.activateSubscription = subscription.activateSubscription;
93
102
  exports.cancelSubscription = subscription.cancelSubscription;
94
103
  exports.createSubscription = subscription.createSubscription;
@@ -101,11 +110,6 @@ exports.updateSubscription = subscription.updateSubscription;
101
110
  exports.updateSubscriptionAddress = subscription.updateSubscriptionAddress;
102
111
  exports.updateSubscriptionChargeDate = subscription.updateSubscriptionChargeDate;
103
112
  exports.updateSubscriptions = subscription.updateSubscriptions;
104
- exports.getCustomer = customer.getCustomer;
105
- exports.getCustomerPortalAccess = customer.getCustomerPortalAccess;
106
- exports.getDeliverySchedule = customer.getDeliverySchedule;
107
- exports.sendCustomerNotification = customer.sendCustomerNotification;
108
- exports.updateCustomer = customer.updateCustomer;
109
113
  exports.api = init.api;
110
114
  exports.initRecharge = init.initRecharge;
111
115
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -62,8 +62,14 @@ async function getDeliverySchedule(session, query) {
62
62
  return deliveries;
63
63
  }
64
64
  async function getCustomerPortalAccess(session) {
65
- const access = await rechargeApiRequest("get", "/portal_access", {}, session);
66
- return access;
65
+ return rechargeApiRequest("get", "/portal_access", {}, session);
66
+ }
67
+ async function getActiveChurnLandingPageURL(session, subscriptionId, redirectURL) {
68
+ const { base_url, customer_hash, temp_token } = await getCustomerPortalAccess(session);
69
+ return `${base_url.replace(
70
+ "portal",
71
+ "pages"
72
+ )}${customer_hash}/subscriptions/${subscriptionId}/cancel?token=${temp_token}&subscription=${subscriptionId}&redirect_to=${redirectURL}`;
67
73
  }
68
74
  const customerNotificationMap = {
69
75
  SHOPIFY_UPDATE_PAYMENT_INFO: {
@@ -91,6 +97,21 @@ async function sendCustomerNotification(session, notification, options) {
91
97
  session
92
98
  );
93
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 rechargeApiRequest(
106
+ "get",
107
+ `/customers/${id}/credit_summary`,
108
+ {
109
+ query: { include: options == null ? void 0 : options.include }
110
+ },
111
+ session
112
+ );
113
+ return credit_summary;
114
+ }
94
115
 
95
- export { getCustomer, getCustomerPortalAccess, getDeliverySchedule, sendCustomerNotification, updateCustomer };
116
+ export { getActiveChurnLandingPageURL, getCreditSummary, getCustomer, getCustomerPortalAccess, getDeliverySchedule, sendCustomerNotification, updateCustomer };
96
117
  //# sourceMappingURL=customer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"customer.js","sources":["../../../src/api/customer.ts"],"sourcesContent":["import { Session } from '../types/session';\nimport {\n Customer,\n CustomerDeliveryScheduleParams,\n CustomerDeliveryScheduleResponse,\n CustomerNotification,\n CustomerNotificationOptions,\n CustomerNotificationTemplate,\n CustomerNotificationType,\n CustomerPortalAccessResponse,\n Delivery,\n GetCustomerOptions,\n UpdateCustomerRequest,\n} from '../types/customer';\nimport { 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 session\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 session\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 session\n );\n return deliveries;\n}\n\nexport async function getCustomerPortalAccess(session: Session): Promise<CustomerPortalAccessResponse> {\n const access = await rechargeApiRequest<CustomerPortalAccessResponse>('get', '/portal_access', {}, session);\n return access;\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 session\n );\n}\n"],"names":[],"mappings":";;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,UAAU,GAAG,MAAM,CAAC,gBAAgB,CAAC;AACzC,IAAI,iBAAiB,GAAG,MAAM,CAAC,yBAAyB,CAAC;AACzD,IAAI,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC;AACvD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC;AACnD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,oBAAoB,CAAC;AACzD,IAAI,eAAe,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,KAAK,GAAG,IAAI,GAAG,GAAG,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAChK,IAAI,cAAc,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK;AAC/B,EAAE,KAAK,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;AAChC,IAAI,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC;AAClC,MAAM,eAAe,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AACxC,EAA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AAI,CAAC,IAAI,EAAE;AACb,IAAI,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;AACnD,GAAG;AACH,EAAE,OAAO,kBAAkB;AAC3B,IAAI,MAAM;AACV,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,cAAc,CAAC;AAC5C,IAAI;AACJ,MAAM,IAAI,EAAE,aAAa,CAAC,cAAc,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE;AACpD,QAAQ,aAAa,EAAE,OAAO;AAC9B,OAAO,CAAC;AACR,KAAK;AACL,IAAI,OAAO;AACX,GAAG,CAAC;AACJ;;;;"}
1
+ {"version":3,"file":"customer.js","sources":["../../../src/api/customer.ts"],"sourcesContent":["import { Session } from '../types/session';\nimport {\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} from '../types/customer';\nimport { 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 session\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 session\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 session\n );\n return deliveries;\n}\n\nexport async function getCustomerPortalAccess(session: Session): Promise<CustomerPortalAccessResponse> {\n return rechargeApiRequest<CustomerPortalAccessResponse>('get', '/portal_access', {}, session);\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(session);\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\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 session\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 session\n );\n return credit_summary;\n}\n"],"names":[],"mappings":";;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,UAAU,GAAG,MAAM,CAAC,gBAAgB,CAAC;AACzC,IAAI,i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,EAAE,OAAO,kBAAkB;AAC3B,IAAI,MAAM;AACV,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,cAAc,CAAC;AAC5C,IAAI;AACJ,MAAM,IAAI,EAAE,aAAa,CAAC,cAAc,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE;AACpD,QAAQ,aAAa,EAAE,OAAO;AAC9B,OAAO,CAAC;AACR,KAAK;AACL,IAAI,OAAO;AACX,GAAG,CAAC;AACJ,CAAC;AACM,eAAe,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE;AACzD,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC;AAChC,EAAE,IAAI,CAAC,EAAE,EAAE;AACX,IAAI,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;AACtC,GAAG;AACH,EAAE,MAAM,EAAE,cAAc,EAAE,GAAG,MAAM,kBAAkB;AACrD,IAAI,KAAK;AACT,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC,eAAe,CAAC;AACrC,IAAI;AACJ,MAAM,KAAK,EAAE,EAAE,OAAO,EAAE,OAAO,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,OAAO,CAAC,OAAO,EAAE;AACpE,KAAK;AACL,IAAI,OAAO;AACX,GAAG,CAAC;AACJ,EAAE,OAAO,cAAc,CAAC;AACxB;;;;"}
@@ -0,0 +1,20 @@
1
+ import { rechargeApiRequest } from '../utils/request.js';
2
+
3
+ async function getShippingCountries(session, options) {
4
+ const response = await rechargeApiRequest(
5
+ "get",
6
+ `/shop/shipping_countries`,
7
+ {
8
+ query: options,
9
+ headers: {
10
+ // Currently this is only available on the older api version.
11
+ "X-Recharge-Version": "2021-01"
12
+ }
13
+ },
14
+ session
15
+ );
16
+ return response;
17
+ }
18
+
19
+ export { getShippingCountries };
20
+ //# sourceMappingURL=store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.js","sources":["../../../src/api/store.ts"],"sourcesContent":["import { Session } from '../types/session';\nimport { ShippingCountriesOptions, ShippingCountriesResponse, ShippingCountry } from '../types/store';\nimport { 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 session\n );\n return response;\n}\n"],"names":[],"mappings":";;AACO,eAAe,oBAAoB,CAAC,OAAO,EAAE,OAAO,EAAE;AAC7D,EAAE,MAAM,QAAQ,GAAG,MAAM,kBAAkB;AAC3C,IAAI,KAAK;AACT,IAAI,CAAC,wBAAwB,CAAC;AAC9B,IAAI;AACJ,MAAM,KAAK,EAAE,OAAO;AACpB,MAAM,OAAO,EAAE;AACf;AACA,QAAQ,oBAAoB,EAAE,SAAS;AACvC,OAAO;AACP,KAAK;AACL,IAAI,OAAO;AACX,GAAG,CAAC;AACJ,EAAE,OAAO,QAAQ,CAAC;AAClB;;;;"}
package/dist/esm/index.js CHANGED
@@ -1,8 +1,9 @@
1
1
  export { applyDiscountToAddress, createAddress, deleteAddress, getAddress, listAddresses, mergeAddresses, removeDiscountsFromAddress, skipFutureCharge, updateAddress } from './api/address.js';
2
2
  export { loginCustomerPortal, loginShopifyApi, loginShopifyAppProxy, sendPasswordlessCode, sendPasswordlessCodeAppProxy, validatePasswordlessCode, validatePasswordlessCodeAppProxy } from './api/auth.js';
3
- export { applyDiscountToCharge, getCharge, listCharges, processCharge, removeDiscountsFromCharge, skipCharge, unskipCharge } from './api/charge.js';
4
- export { getCDNBundleSettings, getCDNProduct, getCDNProductAndSettings, getCDNProducts, getCDNProductsAndSettings, getCDNStoreSettings, getCDNWidgetSettings, resetCDNCache } from './api/cdn.js';
5
3
  export { createBundleSelection, deleteBundleSelection, getBundleId, getBundleSelection, getDynamicBundleItems, listBundleSelections, updateBundle, updateBundleSelection, validateBundle, validateDynamicBundle } from './api/bundle.js';
4
+ export { getCDNBundleSettings, getCDNProduct, getCDNProductAndSettings, getCDNProducts, getCDNProductsAndSettings, getCDNStoreSettings, getCDNWidgetSettings, resetCDNCache } from './api/cdn.js';
5
+ export { applyDiscountToCharge, getCharge, listCharges, processCharge, removeDiscountsFromCharge, skipCharge, unskipCharge } from './api/charge.js';
6
+ export { getActiveChurnLandingPageURL, getCreditSummary, getCustomer, getCustomerPortalAccess, getDeliverySchedule, sendCustomerNotification, updateCustomer } from './api/customer.js';
6
7
  export { getGiftPurchase, listGiftPurchases } from './api/gift.js';
7
8
  export { activateMembership, cancelMembership, changeMembership, getMembership, listMemberships } from './api/membership.js';
8
9
  export { getMembershipProgram, listMembershipPrograms } from './api/membershipProgram.js';
@@ -12,7 +13,7 @@ export { getOrder, listOrders } from './api/order.js';
12
13
  export { createPaymentMethod, getPaymentMethod, listPaymentMethods, updatePaymentMethod } from './api/paymentMethod.js';
13
14
  export { getPlan, listPlans } from './api/plan.js';
14
15
  export { productSearch } from './api/product.js';
16
+ export { getShippingCountries } from './api/store.js';
15
17
  export { activateSubscription, cancelSubscription, createSubscription, createSubscriptions, getSubscription, listSubscriptions, skipGiftSubscriptionCharge, skipSubscriptionCharge, updateSubscription, updateSubscriptionAddress, updateSubscriptionChargeDate, updateSubscriptions } from './api/subscription.js';
16
- export { getCustomer, getCustomerPortalAccess, getDeliverySchedule, sendCustomerNotification, updateCustomer } from './api/customer.js';
17
18
  export { api, initRecharge } from './utils/init.js';
18
19
  //# sourceMappingURL=index.js.map
@@ -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
@@ -881,6 +881,48 @@ interface CustomerPortalAccessResponse {
881
881
  /** Token for use with customer portal */
882
882
  temp_token: string;
883
883
  }
884
+ type CreditSummaryIncludes = 'credit_details';
885
+ interface GetCreditSummaryOptions {
886
+ include?: CreditSummaryIncludes[];
887
+ }
888
+ type CreditAccountType = 'reward' | 'manual' | 'gift';
889
+ interface CreditAccount {
890
+ /** id of the credit account */
891
+ id: number;
892
+ /** Customer the credit account is associated with */
893
+ customer_id: number;
894
+ /** Store the credit account is associated with */
895
+ store_id: number;
896
+ /** Current balance of the credit account */
897
+ available_balance: string;
898
+ /** When the credit account was created */
899
+ created_at: IsoDateString;
900
+ /** Currency of the credit account */
901
+ currency_code: string;
902
+ /** When the credit account expires */
903
+ expires_at: IsoDateString | null;
904
+ /** Name of the credit account */
905
+ name: string;
906
+ /** Redemption_code associated with credit account */
907
+ redemption_code: string;
908
+ /** The last time the credit account was updated */
909
+ updated_at: IsoDateString;
910
+ api_client_id: number;
911
+ api_client_restricted: boolean;
912
+ /** Type of credit account */
913
+ type: CreditAccountType;
914
+ }
915
+ interface CustomerCreditSummary {
916
+ /** Unique numeric identifier for the Customer. */
917
+ customer_id: number;
918
+ /** The total balance of the customer’s credit accounts. */
919
+ total_available_balance: string;
920
+ /** The currency of the customer’s credit balance. */
921
+ currency_code: string;
922
+ includes?: {
923
+ credit_details: CreditAccount[];
924
+ };
925
+ }
884
926
 
885
927
  interface ShippingLine {
886
928
  /** The code associated with the shipping_line of a Charge. */
@@ -2370,6 +2412,71 @@ interface InitOptions {
2370
2412
  loginRetryFn?: () => Promise<Session | undefined>;
2371
2413
  }
2372
2414
 
2415
+ interface ShippingCountriesResponse {
2416
+ shipping_countries: ShippingCountry[];
2417
+ }
2418
+ interface ShippingCountriesOptions {
2419
+ /**
2420
+ * Show all available countries.
2421
+ * When this is `false` or `undefined` only the configured shipping countries will be returned.
2422
+ */
2423
+ display_all?: boolean;
2424
+ /**
2425
+ * Limit the number of records returned.
2426
+ * @default 250
2427
+ */
2428
+ limit?: number;
2429
+ }
2430
+ interface ShippingProvince {
2431
+ /** The province code. e.g. California is `CA` */
2432
+ code: string;
2433
+ /** Id for the shipping province record */
2434
+ id: number;
2435
+ /** The name of the province. e.g. `California` */
2436
+ name: string;
2437
+ }
2438
+ interface ShippingCountry {
2439
+ /** The country code. e.g. United States is `US` */
2440
+ code: string;
2441
+ /** The country id */
2442
+ country_id: number;
2443
+ /** Id for the country record */
2444
+ id: number;
2445
+ /** The full name of the country. e.g. `United States` */
2446
+ name: string;
2447
+ /**
2448
+ * List of provinces for the country.
2449
+ * Some countries have no defined provinces. This array will be empty in that case.
2450
+ */
2451
+ provinces: ShippingProvince[];
2452
+ }
2453
+
2454
+ declare function getBundleId(bundle: BundleAppProxy): Promise<string>;
2455
+ declare function getDynamicBundleItems(bundle: BundleAppProxy, shopifyProductHandle: string): DynamicBundleItemAppProxy[];
2456
+ declare function validateBundle(bundle: BundleAppProxy): Promise<true | string>;
2457
+ /**
2458
+ * Validates a dynamic bundle
2459
+ *
2460
+ * @param bundle Dynamic Bundle being validated
2461
+ * @returns true or error message
2462
+ */
2463
+ declare function validateDynamicBundle(bundle: BundleAppProxy): true | string;
2464
+ declare function getBundleSelection(session: Session, id: string | number): Promise<BundleSelection>;
2465
+ declare function listBundleSelections(session: Session, query?: BundleSelectionListParams): Promise<BundleSelectionsResponse>;
2466
+ declare function createBundleSelection(session: Session, createRequest: CreateBundleSelectionRequest): Promise<BundleSelection>;
2467
+ declare function updateBundleSelection(session: Session, id: string | number, updateRequest: UpdateBundleSelectionRequest): Promise<BundleSelection>;
2468
+ declare function deleteBundleSelection(session: Session, id: string | number): Promise<void>;
2469
+ declare function updateBundle(session: Session, purchase_item_id: string | number, updateRequest: UpdateBundlePurchaseItem, query?: BundlePurchaseItemParams): Promise<BundlePurchaseItem>;
2470
+
2471
+ declare function getCDNProduct<T extends CDNProductQuery_2020_12 | CDNProductQuery_2022_06 = CDNProductQuery_2020_12>(externalProductId: string | number, query?: T): Promise<CDNProductType<T>>;
2472
+ declare function getCDNStoreSettings(): Promise<CDNStoreSettings>;
2473
+ declare function getCDNWidgetSettings(): Promise<CDNWidgetSettings>;
2474
+ declare function getCDNProductsAndSettings(): Promise<CDNProductsAndSettings>;
2475
+ declare function getCDNProducts(): Promise<CDNProductKeyObject[]>;
2476
+ declare function getCDNProductAndSettings(externalProductId: string | number): Promise<CDNProductAndSettings>;
2477
+ declare function getCDNBundleSettings(externalProductId: string | number): Promise<CDNBundleSettings | null | undefined>;
2478
+ declare function resetCDNCache(): Promise<void>;
2479
+
2373
2480
  declare function getCharge(session: Session, id: number | string, options?: GetChargeOptions): Promise<Charge>;
2374
2481
  /** Lists charges */
2375
2482
  declare function listCharges(session: Session, query?: ChargeListParams): Promise<ChargeListResponse>;
@@ -2390,31 +2497,13 @@ declare function skipCharge(session: Session, id: number | string, purchaseItemI
2390
2497
  declare function unskipCharge(session: Session, id: number | string, purchaseItemIds: (string | number)[]): Promise<Charge>;
2391
2498
  declare function processCharge(session: Session, id: number | string): Promise<Charge>;
2392
2499
 
2393
- declare function getCDNProduct<T extends CDNProductQuery_2020_12 | CDNProductQuery_2022_06 = CDNProductQuery_2020_12>(externalProductId: string | number, query?: T): Promise<CDNProductType<T>>;
2394
- declare function getCDNStoreSettings(): Promise<CDNStoreSettings>;
2395
- declare function getCDNWidgetSettings(): Promise<CDNWidgetSettings>;
2396
- declare function getCDNProductsAndSettings(): Promise<CDNProductsAndSettings>;
2397
- declare function getCDNProducts(): Promise<CDNProductKeyObject[]>;
2398
- declare function getCDNProductAndSettings(externalProductId: string | number): Promise<CDNProductAndSettings>;
2399
- declare function getCDNBundleSettings(externalProductId: string | number): Promise<CDNBundleSettings | null | undefined>;
2400
- declare function resetCDNCache(): Promise<void>;
2401
-
2402
- declare function getBundleId(bundle: BundleAppProxy): Promise<string>;
2403
- declare function getDynamicBundleItems(bundle: BundleAppProxy, shopifyProductHandle: string): DynamicBundleItemAppProxy[];
2404
- declare function validateBundle(bundle: BundleAppProxy): Promise<true | string>;
2405
- /**
2406
- * Validates a dynamic bundle
2407
- *
2408
- * @param bundle Dynamic Bundle being validated
2409
- * @returns true or error message
2410
- */
2411
- declare function validateDynamicBundle(bundle: BundleAppProxy): true | string;
2412
- declare function getBundleSelection(session: Session, id: string | number): Promise<BundleSelection>;
2413
- declare function listBundleSelections(session: Session, query?: BundleSelectionListParams): Promise<BundleSelectionsResponse>;
2414
- declare function createBundleSelection(session: Session, createRequest: CreateBundleSelectionRequest): Promise<BundleSelection>;
2415
- declare function updateBundleSelection(session: Session, id: string | number, updateRequest: UpdateBundleSelectionRequest): Promise<BundleSelection>;
2416
- declare function deleteBundleSelection(session: Session, id: string | number): Promise<void>;
2417
- declare function updateBundle(session: Session, purchase_item_id: string | number, updateRequest: UpdateBundlePurchaseItem, query?: BundlePurchaseItemParams): Promise<BundlePurchaseItem>;
2500
+ declare function getCustomer(session: Session, options?: GetCustomerOptions): Promise<Customer>;
2501
+ declare function updateCustomer(session: Session, updateRequest: UpdateCustomerRequest): Promise<Customer>;
2502
+ declare function getDeliverySchedule(session: Session, query?: CustomerDeliveryScheduleParams): Promise<Delivery[]>;
2503
+ declare function getCustomerPortalAccess(session: Session): Promise<CustomerPortalAccessResponse>;
2504
+ declare function getActiveChurnLandingPageURL(session: Session, subscriptionId: string | number, redirectURL: string): Promise<string>;
2505
+ declare function sendCustomerNotification<T extends CustomerNotification>(session: Session, notification: CustomerNotification, options?: CustomerNotificationOptions<T>): Promise<void>;
2506
+ declare function getCreditSummary(session: Session, options?: GetCreditSummaryOptions): Promise<CustomerCreditSummary>;
2418
2507
 
2419
2508
  declare function listGiftPurchases(session: Session, options?: GiftPurchasesParams): Promise<GiftPurchasesResponse>;
2420
2509
  declare function getGiftPurchase(session: Session, id: number): Promise<GiftPurchase>;
@@ -2469,6 +2558,11 @@ declare function listPlans(session: Session, query?: PlanListParams): Promise<Pl
2469
2558
  type ProductSearchType<T extends ProductSearchParams_2020_12 | ProductSearchParams_2022_06> = T extends ProductSearchParams_2020_12 ? ProductSearchResponse_2020_12 : ProductSearchResponse_2022_06;
2470
2559
  declare function productSearch<T extends ProductSearchParams_2020_12 | ProductSearchParams_2022_06>(session: Session, query: T): Promise<ProductSearchType<T>>;
2471
2560
 
2561
+ /**
2562
+ * Get a list of all shipping countries for the store.
2563
+ */
2564
+ declare function getShippingCountries(session: Session, options?: ShippingCountriesOptions): Promise<ShippingCountriesResponse>;
2565
+
2472
2566
  declare function getSubscription(session: Session, id: string | number, options?: GetSubscriptionOptions): Promise<Subscription>;
2473
2567
  declare function listSubscriptions(session: Session, query?: SubscriptionListParams): Promise<SubscriptionsResponse>;
2474
2568
  /**
@@ -2522,12 +2616,6 @@ declare function createSubscriptions(session: Session, createRequestBulk: Create
2522
2616
  */
2523
2617
  declare function updateSubscriptions(session: Session, addressId: string | number, updateRequestBulk: UpdateSubscriptionsRequest[], query?: UpdateSubscriptionsParams): Promise<Subscription[]>;
2524
2618
 
2525
- declare function getCustomer(session: Session, options?: GetCustomerOptions): Promise<Customer>;
2526
- declare function updateCustomer(session: Session, updateRequest: UpdateCustomerRequest): Promise<Customer>;
2527
- declare function getDeliverySchedule(session: Session, query?: CustomerDeliveryScheduleParams): Promise<Delivery[]>;
2528
- declare function getCustomerPortalAccess(session: Session): Promise<CustomerPortalAccessResponse>;
2529
- declare function sendCustomerNotification<T extends CustomerNotification>(session: Session, notification: CustomerNotification, options?: CustomerNotificationOptions<T>): Promise<void>;
2530
-
2531
2619
  declare const api: {
2532
2620
  get<T>(url: string, requestOptions?: GetRequestOptions): Promise<T>;
2533
2621
  post<T_1>(url: string, requestOptions?: CRUDRequestOptions): Promise<T_1>;
@@ -2536,4 +2624,4 @@ declare const api: {
2536
2624
  };
2537
2625
  declare function initRecharge(opt?: InitOptions): void;
2538
2626
 
2539
- export { ActivateMembershipRequest, Address, AddressIncludes, AddressListParams, AddressListResponse, AddressResponse, AddressSortBy, AnalyticsData, AssociatedAddress, BasicSubscriptionParams, BooleanLike, BooleanNumbers, BooleanString, BooleanStringNumbers, BundleAppProxy, BundleProduct, BundlePurchaseItem, BundlePurchaseItemParams, BundleSelection, BundleSelectionAppProxy, BundleSelectionItem, BundleSelectionItemRequiredCreateProps, BundleSelectionListParams, BundleSelectionsResponse, BundleSelectionsSortBy, BundleTranslations, BundleVariant, BundleVariantOptionSource, CDNBaseWidgetSettings, CDNBundleSettings, CDNBundleVariant, CDNBundleVariantOptionSource, CDNPlan, CDNProduct, CDNProductAndSettings, CDNProductKeyObject, CDNProductQuery_2020_12, CDNProductQuery_2022_06, CDNProductRaw, CDNProductResource, CDNProductResponseType, CDNProductType, CDNProductVariant_2022_06, CDNProduct_2022_06, CDNProductsAndSettings, CDNProductsAndSettingsResource, CDNStoreSettings, CDNSubscriptionOption, CDNVariant, CDNVersion, CDNWidgetSettings, CDNWidgetSettingsRaw, CDNWidgetSettingsResource, CRUDRequestOptions, CancelMembershipRequest, CancelSubscriptionRequest, ChangeMembershipRequest, ChannelSettings, Charge, ChargeIncludes, ChargeListParams, ChargeListResponse, ChargeResponse, ChargeSortBy, ChargeStatus, ColorString, CreateAddressRequest, CreateBundleSelectionRequest, CreateMetafieldRequest, CreateOnetimeRequest, CreatePaymentMethodRequest, CreateRecipientAddress, CreateSubscriptionRequest, Customer, CustomerDeliveryScheduleParams, CustomerDeliveryScheduleResponse, CustomerIncludes, CustomerNotification, CustomerNotificationOptions, CustomerNotificationTemplate, CustomerNotificationType, CustomerPortalAccessResponse, Delivery, DeliveryLineItem, DeliveryOrder, DeliveryPaymentMethod, Discount, DiscountType, DynamicBundleItemAppProxy, DynamicBundlePropertiesAppProxy, ExternalAttributeSchema, ExternalId, ExternalTransactionId, FirstOption, GetAddressOptions, GetChargeOptions, GetCustomerOptions, GetMembershipProgramOptions, GetPaymentMethodOptions, GetRequestOptions, GetSubscriptionOptions, GiftPurchase, GiftPurchasesParams, GiftPurchasesResponse, HTMLString, InitOptions, IntervalUnit, IsoDateString, LineItem, ListParams, LoginResponse, Membership, MembershipBenefit, MembershipIncludes, MembershipListParams, MembershipListResponse, MembershipProgram, MembershipProgramIncludes, MembershipProgramListParams, MembershipProgramListResponse, MembershipProgramResponse, MembershipProgramSortBy, MembershipProgramStatus, MembershipResponse, MembershipStatus, MembershipsSortBy, MergeAddressesRequest, Metafield, MetafieldOptionalCreateProps, MetafieldOwnerResource, MetafieldRequiredCreateProps, Method, Modifier, Onetime, OnetimeListParams, OnetimeOptionalCreateProps, OnetimeRequiredCreateProps, OnetimesResponse, OnetimesSortBy, Order, OrderIncludes, OrderListParams, OrderSortBy, OrderStatus, OrderType, OrdersResponse, PasswordlessCodeResponse, PasswordlessOptions, PasswordlessValidateResponse, PaymentDetails, PaymentMethod, PaymentMethodIncludes, PaymentMethodListParams, PaymentMethodOptionalCreateProps, PaymentMethodRequiredCreateProps, PaymentMethodSortBy, PaymentMethodStatus, PaymentMethodsResponse, PaymentType, Plan, PlanListParams, PlanSortBy, PlanType, PlansResponse, ProcessorName, ProductImage, ProductInclude, ProductOption, ProductSearchParams_2020_12, ProductSearchParams_2022_06, ProductSearchResponse_2020_12, ProductSearchResponse_2022_06, ProductSearchType, ProductSource, ProductValueOption, ProductVariant_2020_12, ProductVariant_2022_06, Product_2020_12, Product_2022_06, Property, PublishStatus, Request, RequestHeaders, RequestOptions, SellingPlan, SellingPlanGroup, Session, ShippingLine, ShopifyUpdatePaymentInfoOptions, SkipFutureChargeAddressRequest, SkipFutureChargeAddressResponse, SortBy, SortField, SortKeys, StorefrontEnvironment, StorefrontOptions, StorefrontPurchaseOption, SubType, Subscription, SubscriptionIncludes, SubscriptionListParams, SubscriptionOption, SubscriptionOptionalCreateProps, SubscriptionPreferences, SubscriptionRequiredCreateProps, SubscriptionSortBy, SubscriptionStatus, Subscription_2021_01, SubscriptionsResponse, TaxLine, Translations, UpdateAddressRequest, UpdateBundlePurchaseItem, UpdateBundleSelectionRequest, UpdateCustomerRequest, UpdateMetafieldRequest, UpdateOnetimeRequest, UpdatePaymentMethodRequest, UpdateSubscriptionParams, UpdateSubscriptionRequest, UpdateSubscriptionsParams, UpdateSubscriptionsRequest, WidgetIconColor, WidgetTemplateType, activateMembership, activateSubscription, api, applyDiscountToAddress, applyDiscountToCharge, cancelMembership, cancelSubscription, changeMembership, createAddress, createBundleSelection, createMetafield, createOnetime, createPaymentMethod, createSubscription, createSubscriptions, deleteAddress, deleteBundleSelection, deleteMetafield, deleteOnetime, getAddress, getBundleId, getBundleSelection, getCDNBundleSettings, getCDNProduct, getCDNProductAndSettings, getCDNProducts, getCDNProductsAndSettings, getCDNStoreSettings, getCDNWidgetSettings, getCharge, getCustomer, getCustomerPortalAccess, getDeliverySchedule, getDynamicBundleItems, getGiftPurchase, getMembership, getMembershipProgram, getOnetime, getOrder, getPaymentMethod, getPlan, getSubscription, initRecharge, intervalUnit, listAddresses, listBundleSelections, listCharges, listGiftPurchases, listMembershipPrograms, listMemberships, listOnetimes, listOrders, listPaymentMethods, listPlans, listSubscriptions, loginCustomerPortal, loginShopifyApi, loginShopifyAppProxy, 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 };
2627
+ export { ActivateMembershipRequest, Address, AddressIncludes, AddressListParams, AddressListResponse, AddressResponse, AddressSortBy, AnalyticsData, AssociatedAddress, BasicSubscriptionParams, BooleanLike, BooleanNumbers, BooleanString, BooleanStringNumbers, BundleAppProxy, BundleProduct, BundlePurchaseItem, BundlePurchaseItemParams, BundleSelection, BundleSelectionAppProxy, BundleSelectionItem, BundleSelectionItemRequiredCreateProps, BundleSelectionListParams, BundleSelectionsResponse, BundleSelectionsSortBy, BundleTranslations, BundleVariant, BundleVariantOptionSource, CDNBaseWidgetSettings, CDNBundleSettings, CDNBundleVariant, CDNBundleVariantOptionSource, CDNPlan, CDNProduct, CDNProductAndSettings, CDNProductKeyObject, CDNProductQuery_2020_12, CDNProductQuery_2022_06, CDNProductRaw, CDNProductResource, CDNProductResponseType, CDNProductType, CDNProductVariant_2022_06, CDNProduct_2022_06, CDNProductsAndSettings, CDNProductsAndSettingsResource, CDNStoreSettings, CDNSubscriptionOption, CDNVariant, CDNVersion, CDNWidgetSettings, CDNWidgetSettingsRaw, CDNWidgetSettingsResource, CRUDRequestOptions, CancelMembershipRequest, CancelSubscriptionRequest, ChangeMembershipRequest, ChannelSettings, Charge, ChargeIncludes, ChargeListParams, ChargeListResponse, ChargeResponse, ChargeSortBy, ChargeStatus, ColorString, CreateAddressRequest, CreateBundleSelectionRequest, CreateMetafieldRequest, CreateOnetimeRequest, CreatePaymentMethodRequest, CreateRecipientAddress, CreateSubscriptionRequest, CreditAccount, CreditAccountType, CreditSummaryIncludes, Customer, CustomerCreditSummary, CustomerDeliveryScheduleParams, CustomerDeliveryScheduleResponse, CustomerIncludes, CustomerNotification, CustomerNotificationOptions, CustomerNotificationTemplate, CustomerNotificationType, CustomerPortalAccessResponse, Delivery, DeliveryLineItem, DeliveryOrder, DeliveryPaymentMethod, Discount, DiscountType, DynamicBundleItemAppProxy, DynamicBundlePropertiesAppProxy, ExternalAttributeSchema, ExternalId, ExternalTransactionId, FirstOption, GetAddressOptions, GetChargeOptions, GetCreditSummaryOptions, GetCustomerOptions, GetMembershipProgramOptions, GetPaymentMethodOptions, GetRequestOptions, GetSubscriptionOptions, GiftPurchase, GiftPurchasesParams, GiftPurchasesResponse, HTMLString, InitOptions, IntervalUnit, IsoDateString, LineItem, ListParams, LoginResponse, Membership, MembershipBenefit, MembershipIncludes, MembershipListParams, MembershipListResponse, MembershipProgram, MembershipProgramIncludes, MembershipProgramListParams, MembershipProgramListResponse, MembershipProgramResponse, MembershipProgramSortBy, MembershipProgramStatus, MembershipResponse, MembershipStatus, MembershipsSortBy, MergeAddressesRequest, Metafield, MetafieldOptionalCreateProps, MetafieldOwnerResource, MetafieldRequiredCreateProps, Method, Modifier, Onetime, OnetimeListParams, OnetimeOptionalCreateProps, OnetimeRequiredCreateProps, OnetimesResponse, OnetimesSortBy, Order, OrderIncludes, OrderListParams, OrderSortBy, OrderStatus, OrderType, OrdersResponse, PasswordlessCodeResponse, PasswordlessOptions, PasswordlessValidateResponse, PaymentDetails, PaymentMethod, PaymentMethodIncludes, PaymentMethodListParams, PaymentMethodOptionalCreateProps, PaymentMethodRequiredCreateProps, PaymentMethodSortBy, PaymentMethodStatus, PaymentMethodsResponse, PaymentType, Plan, PlanListParams, PlanSortBy, PlanType, PlansResponse, ProcessorName, ProductImage, ProductInclude, ProductOption, ProductSearchParams_2020_12, ProductSearchParams_2022_06, ProductSearchResponse_2020_12, ProductSearchResponse_2022_06, ProductSearchType, ProductSource, ProductValueOption, ProductVariant_2020_12, ProductVariant_2022_06, Product_2020_12, Product_2022_06, Property, PublishStatus, Request, RequestHeaders, RequestOptions, SellingPlan, SellingPlanGroup, Session, ShippingCountriesOptions, ShippingCountriesResponse, ShippingCountry, ShippingLine, ShippingProvince, ShopifyUpdatePaymentInfoOptions, SkipFutureChargeAddressRequest, SkipFutureChargeAddressResponse, SortBy, SortField, SortKeys, StorefrontEnvironment, StorefrontOptions, StorefrontPurchaseOption, SubType, Subscription, SubscriptionIncludes, SubscriptionListParams, SubscriptionOption, SubscriptionOptionalCreateProps, SubscriptionPreferences, SubscriptionRequiredCreateProps, SubscriptionSortBy, SubscriptionStatus, Subscription_2021_01, SubscriptionsResponse, TaxLine, Translations, UpdateAddressRequest, UpdateBundlePurchaseItem, UpdateBundleSelectionRequest, UpdateCustomerRequest, UpdateMetafieldRequest, UpdateOnetimeRequest, UpdatePaymentMethodRequest, UpdateSubscriptionParams, UpdateSubscriptionRequest, UpdateSubscriptionsParams, UpdateSubscriptionsRequest, WidgetIconColor, WidgetTemplateType, activateMembership, activateSubscription, api, applyDiscountToAddress, applyDiscountToCharge, cancelMembership, cancelSubscription, changeMembership, createAddress, createBundleSelection, createMetafield, createOnetime, createPaymentMethod, createSubscription, createSubscriptions, deleteAddress, deleteBundleSelection, deleteMetafield, deleteOnetime, getActiveChurnLandingPageURL, getAddress, getBundleId, getBundleSelection, getCDNBundleSettings, getCDNProduct, getCDNProductAndSettings, getCDNProducts, getCDNProductsAndSettings, getCDNStoreSettings, getCDNWidgetSettings, getCharge, getCreditSummary, getCustomer, getCustomerPortalAccess, getDeliverySchedule, getDynamicBundleItems, getGiftPurchase, getMembership, getMembershipProgram, getOnetime, getOrder, getPaymentMethod, getPlan, getShippingCountries, getSubscription, initRecharge, intervalUnit, listAddresses, listBundleSelections, listCharges, listGiftPurchases, listMembershipPrograms, listMemberships, listOnetimes, listOrders, listPaymentMethods, listPlans, listSubscriptions, loginCustomerPortal, loginShopifyApi, loginShopifyAppProxy, 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 };