skikrumb-api 1.3.3 → 1.3.5

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
@@ -9,6 +9,15 @@ export declare const skiKrumb: (options?: {
9
9
  createDeviceDownlink: (userId: string, deveui: string, type?: string) => Promise<any>;
10
10
  createPaymentIntent: (form: any) => Promise<any>;
11
11
  createPrePurchaseIntent: (form: any) => Promise<any>;
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, cartId: string, productId: string, registrations: Array<string>) => Promise<any>;
20
+ cancelSubscription: (subscriptionId: string) => Promise<any>;
12
21
  readApiKeys: () => Promise<apiKeys[]>;
13
22
  readDataForDevices: (query: QueryDevice) => Promise<Device[]>;
14
23
  readDeviceDailyDistance: (serialNumber: string, query: QueryDevice) => Promise<Device[]>;
package/dist/index.js CHANGED
@@ -90,6 +90,51 @@ 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, cartId, productId, registrations) => __awaiter(void 0, void 0, void 0, function* () {
114
+ if (!customerId || !cartId || !productId || !registrations) {
115
+ throw new Error('Customer 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: 'price_1Qr1zjBxfFihs4koWNzhkhyX',
122
+ cartId,
123
+ productId,
124
+ quantity: registrations.length,
125
+ registrations,
126
+ },
127
+ })
128
+ .json();
129
+ });
130
+ const cancelSubscription = (subscriptionId) => __awaiter(void 0, void 0, void 0, function* () {
131
+ if (!subscriptionId) {
132
+ throw new Error('Subscription ID is required');
133
+ }
134
+ return api
135
+ .delete(`${options.url}/payments/subscription/${subscriptionId}`)
136
+ .json();
137
+ });
93
138
  const readDeviceData = (serialNumber, query) => __awaiter(void 0, void 0, void 0, function* () {
94
139
  if (!serialNumber)
95
140
  throw new Error('Serial number is required');
@@ -128,6 +173,11 @@ export const skiKrumb = (options = {
128
173
  createDeviceDownlink,
129
174
  createPaymentIntent,
130
175
  createPrePurchaseIntent,
176
+ getPaymentIntent,
177
+ updateCustomerAddress,
178
+ getTaxCalculation,
179
+ createSubscription,
180
+ cancelSubscription,
131
181
  readApiKeys,
132
182
  readDataForDevices,
133
183
  readDeviceDailyDistance,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skikrumb-api",
3
- "version": "1.3.3",
3
+ "version": "1.3.5",
4
4
  "description": "Wrapper for the skiKrumb API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",