skikrumb-api 1.3.4 → 1.3.6

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/index.d.ts CHANGED
@@ -10,6 +10,15 @@ export declare const skiKrumb: (options?: {
10
10
  createPaymentIntent: (form: any) => Promise<any>;
11
11
  createPrePurchaseIntent: (form: any) => Promise<any>;
12
12
  getPaymentIntent: (clientSecret: string) => Promise<any>;
13
+ updateCustomerAddress: (customerId: string, email: string, shipping: object) => Promise<any>;
14
+ getTaxCalculation: (amount: number, reference: string, quantity: number, address: {
15
+ country: string;
16
+ postal_code: string;
17
+ state?: string;
18
+ }) => Promise<any>;
19
+ createSubscription: (customerId: string, priceId: string, cartId: string, productId: string, registrations: Array<string>) => Promise<any>;
20
+ updateSubscription: (subscriptionId: string, quantity: number, registrations: Array<string>) => Promise<any>;
21
+ cancelSubscription: (subscriptionId: string) => Promise<any>;
13
22
  readApiKeys: () => Promise<apiKeys[]>;
14
23
  readDataForDevices: (query: QueryDevice) => Promise<Device[]>;
15
24
  readDeviceDailyDistance: (serialNumber: string, query: QueryDevice) => Promise<Device[]>;
package/dist/index.js CHANGED
@@ -90,6 +90,65 @@ export const skiKrumb = (options = {
90
90
  })
91
91
  .json();
92
92
  });
93
+ const updateCustomerAddress = (customerId, email, shipping) => __awaiter(void 0, void 0, void 0, function* () {
94
+ if (!customerId || !email || !shipping) {
95
+ throw new Error('Customer ID, email, and shipping details are required');
96
+ }
97
+ return api
98
+ .post(`${options.url}/customers/address`, {
99
+ json: { customerId, email, shipping },
100
+ })
101
+ .json();
102
+ });
103
+ const getTaxCalculation = (amount, reference, quantity, address) => __awaiter(void 0, void 0, void 0, function* () {
104
+ if (!amount || !reference || !quantity || !address) {
105
+ throw new Error('Amount, reference, quantity, and address are required');
106
+ }
107
+ return api
108
+ .post(`${options.url}/tax-calculation`, {
109
+ json: { amount, reference, quantity, address },
110
+ })
111
+ .json();
112
+ });
113
+ const createSubscription = (customerId, priceId, cartId, productId, registrations) => __awaiter(void 0, void 0, void 0, function* () {
114
+ if (!customerId || priceId || !cartId || !productId || !registrations) {
115
+ throw new Error('Customer ID, price Id, cart ID, product ID, and registrations are required');
116
+ }
117
+ return api
118
+ .post(`${options.url}/payments/create-subscription`, {
119
+ json: {
120
+ customerId,
121
+ priceId,
122
+ cartId,
123
+ productId,
124
+ quantity: registrations.length,
125
+ registrations,
126
+ },
127
+ })
128
+ .json();
129
+ });
130
+ const updateSubscription = (subscriptionId, quantity, registrations) => __awaiter(void 0, void 0, void 0, function* () {
131
+ if (!subscriptionId) {
132
+ throw new Error('Subscription ID is required');
133
+ }
134
+ return api
135
+ .patch(`${options.url}/payments/update-subscription`, {
136
+ json: {
137
+ subscriptionId,
138
+ quantity,
139
+ registrations,
140
+ },
141
+ })
142
+ .json();
143
+ });
144
+ const cancelSubscription = (subscriptionId) => __awaiter(void 0, void 0, void 0, function* () {
145
+ if (!subscriptionId) {
146
+ throw new Error('Subscription ID is required');
147
+ }
148
+ return api
149
+ .delete(`${options.url}/payments/subscription/${subscriptionId}`)
150
+ .json();
151
+ });
93
152
  const readDeviceData = (serialNumber, query) => __awaiter(void 0, void 0, void 0, function* () {
94
153
  if (!serialNumber)
95
154
  throw new Error('Serial number is required');
@@ -129,6 +188,11 @@ export const skiKrumb = (options = {
129
188
  createPaymentIntent,
130
189
  createPrePurchaseIntent,
131
190
  getPaymentIntent,
191
+ updateCustomerAddress,
192
+ getTaxCalculation,
193
+ createSubscription,
194
+ updateSubscription,
195
+ cancelSubscription,
132
196
  readApiKeys,
133
197
  readDataForDevices,
134
198
  readDeviceDailyDistance,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skikrumb-api",
3
- "version": "1.3.4",
3
+ "version": "1.3.6",
4
4
  "description": "Wrapper for the skiKrumb API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",