skikrumb-api 1.3.7 → 1.3.8

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
@@ -1,4 +1,4 @@
1
- import { apiKeys, Device, Gateways, QueryDevice } from './models';
1
+ import { apiKeys, Device, Gateways, QueryDevice, RateRequest, Rates } from './models';
2
2
  export declare const skiKrumb: (options?: {
3
3
  apiKey: string;
4
4
  supabaseToken: string;
@@ -24,4 +24,5 @@ export declare const skiKrumb: (options?: {
24
24
  readDeviceDailyDistance: (serialNumber: string, query: QueryDevice) => Promise<Device[]>;
25
25
  readDeviceData: (serialNumber: string, query: QueryDevice) => Promise<Device>;
26
26
  readGateways: () => Promise<Gateways>;
27
+ readShippingRates: (payload: RateRequest) => Promise<Rates[]>;
27
28
  };
package/dist/index.js CHANGED
@@ -1,12 +1,3 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import ky from 'ky';
11
2
  export const skiKrumb = (options = {
12
3
  apiKey: '',
@@ -28,10 +19,10 @@ export const skiKrumb = (options = {
28
19
  ],
29
20
  },
30
21
  });
31
- const createDevice = (deveui, serialNumber) => __awaiter(void 0, void 0, void 0, function* () {
22
+ const createDevice = async (deveui, serialNumber) => {
32
23
  if (!deveui || !serialNumber)
33
24
  throw new Error('Must pass Lora MAC (deveui) and Serial Number');
34
- return yield api
25
+ return await api
35
26
  .post(`${options.url}/devices`, {
36
27
  headers: {
37
28
  'content-type': 'application/json',
@@ -39,8 +30,8 @@ export const skiKrumb = (options = {
39
30
  json: { deveui: deveui, serial_number: serialNumber },
40
31
  })
41
32
  .json();
42
- });
43
- const createDeviceDownlink = (userId, deveui, type = 'beep') => __awaiter(void 0, void 0, void 0, function* () {
33
+ };
34
+ const createDeviceDownlink = async (userId, deveui, type = 'beep') => {
44
35
  if (!userId || !deveui || !type)
45
36
  throw new Error('Must pass userId, Lora MAC (deveui) and message type');
46
37
  let message = 'DAgAC04zKE9EPTEwKQ0K';
@@ -49,7 +40,7 @@ export const skiKrumb = (options = {
49
40
  message = 'DBECAAAAAAAAAAAB';
50
41
  break;
51
42
  }
52
- return yield api
43
+ return await api
53
44
  .post(`${options.url}/devices/downlink`, {
54
45
  headers: {
55
46
  'content-type': 'application/json',
@@ -66,8 +57,8 @@ export const skiKrumb = (options = {
66
57
  },
67
58
  })
68
59
  .json();
69
- });
70
- const createPaymentIntent = (form) => __awaiter(void 0, void 0, void 0, function* () {
60
+ };
61
+ const createPaymentIntent = async (form) => {
71
62
  if (!form)
72
63
  throw new Error('Form values not posted.');
73
64
  return api
@@ -75,13 +66,13 @@ export const skiKrumb = (options = {
75
66
  body: form,
76
67
  })
77
68
  .json();
78
- });
79
- const getPaymentIntent = (clientSecret) => __awaiter(void 0, void 0, void 0, function* () {
69
+ };
70
+ const getPaymentIntent = async (clientSecret) => {
80
71
  if (!clientSecret)
81
72
  throw new Error('Client secret is required');
82
73
  return api.get(`${options.url}/payments/intent/${clientSecret}`).json();
83
- });
84
- const createPrePurchaseIntent = (form) => __awaiter(void 0, void 0, void 0, function* () {
74
+ };
75
+ const createPrePurchaseIntent = async (form) => {
85
76
  if (!form)
86
77
  throw new Error('Form values not posted.');
87
78
  return api
@@ -89,8 +80,8 @@ export const skiKrumb = (options = {
89
80
  body: form,
90
81
  })
91
82
  .json();
92
- });
93
- const updateCustomerAddress = (customerId, email, shipping) => __awaiter(void 0, void 0, void 0, function* () {
83
+ };
84
+ const updateCustomerAddress = async (customerId, email, shipping) => {
94
85
  if (!customerId || !email || !shipping) {
95
86
  throw new Error('Customer ID, email, and shipping details are required');
96
87
  }
@@ -99,8 +90,8 @@ export const skiKrumb = (options = {
99
90
  json: { customerId, email, shipping },
100
91
  })
101
92
  .json();
102
- });
103
- const getTaxCalculation = (amount, reference, quantity, address) => __awaiter(void 0, void 0, void 0, function* () {
93
+ };
94
+ const getTaxCalculation = async (amount, reference, quantity, address) => {
104
95
  if (!amount || !reference || !quantity || !address) {
105
96
  throw new Error('Amount, reference, quantity, and address are required');
106
97
  }
@@ -109,8 +100,8 @@ export const skiKrumb = (options = {
109
100
  json: { amount, reference, quantity, address },
110
101
  })
111
102
  .json();
112
- });
113
- const createSubscription = (customerId, priceId, cartId, productId, registrations) => __awaiter(void 0, void 0, void 0, function* () {
103
+ };
104
+ const createSubscription = async (customerId, priceId, cartId, productId, registrations) => {
114
105
  if (!customerId || !priceId || !cartId || !productId || !registrations) {
115
106
  throw new Error('Customer ID, price Id, cart ID, product ID, and registrations are required');
116
107
  }
@@ -126,8 +117,8 @@ export const skiKrumb = (options = {
126
117
  },
127
118
  })
128
119
  .json();
129
- });
130
- const updateSubscription = (subscriptionId, quantity, registrations) => __awaiter(void 0, void 0, void 0, function* () {
120
+ };
121
+ const updateSubscription = async (subscriptionId, quantity, registrations) => {
131
122
  if (!subscriptionId) {
132
123
  throw new Error('Subscription ID is required');
133
124
  }
@@ -140,48 +131,58 @@ export const skiKrumb = (options = {
140
131
  },
141
132
  })
142
133
  .json();
143
- });
144
- const cancelSubscription = (subscriptionId) => __awaiter(void 0, void 0, void 0, function* () {
134
+ };
135
+ const cancelSubscription = async (subscriptionId) => {
145
136
  if (!subscriptionId) {
146
137
  throw new Error('Subscription ID is required');
147
138
  }
148
139
  return api
149
140
  .delete(`${options.url}/payments/subscription/${subscriptionId}`)
150
141
  .json();
151
- });
152
- const readDeviceData = (serialNumber, query) => __awaiter(void 0, void 0, void 0, function* () {
142
+ };
143
+ const readDeviceData = async (serialNumber, query) => {
153
144
  if (!serialNumber)
154
145
  throw new Error('Serial number is required');
155
146
  return api
156
147
  .get(`${options.url}/devices/data/${serialNumber}`, {
157
- searchParams: new URLSearchParams(Object.assign({}, query)),
148
+ searchParams: new URLSearchParams({ ...query }),
158
149
  })
159
150
  .json();
160
- });
161
- const readGateways = () => __awaiter(void 0, void 0, void 0, function* () {
151
+ };
152
+ const readGateways = async () => {
162
153
  return api.get(`${options.url}/gateways`).json();
163
- });
164
- const readDeviceDailyDistance = (serialNumber, query) => __awaiter(void 0, void 0, void 0, function* () {
154
+ };
155
+ const readDeviceDailyDistance = async (serialNumber, query) => {
165
156
  if (!serialNumber)
166
157
  throw new Error('Serial number is required');
167
158
  return api
168
159
  .get(`${options.url}/devices/${serialNumber}/distance`, {
169
- searchParams: new URLSearchParams(Object.assign({}, query)),
160
+ searchParams: new URLSearchParams({ ...query }),
170
161
  })
171
162
  .json();
172
- });
173
- const readDataForDevices = (query) => __awaiter(void 0, void 0, void 0, function* () {
163
+ };
164
+ const readDataForDevices = async (query) => {
174
165
  if (!query.serial_numbers)
175
166
  throw new Error('Serial number is required');
176
167
  return api
177
168
  .get(`${options.url}/devices/data`, {
178
- searchParams: new URLSearchParams(Object.assign({}, query)),
169
+ searchParams: new URLSearchParams({ ...query }),
179
170
  })
180
171
  .json();
181
- });
182
- const readApiKeys = () => __awaiter(void 0, void 0, void 0, function* () {
172
+ };
173
+ const readApiKeys = async () => {
183
174
  return api.get(`${options.url}/keys`).json();
184
- });
175
+ };
176
+ const readShippingRates = async (payload) => {
177
+ return await api
178
+ .post(`${options.url}/payments/shipping-rates`, {
179
+ headers: {
180
+ 'content-type': 'application/json',
181
+ },
182
+ json: payload,
183
+ })
184
+ .json();
185
+ };
185
186
  return {
186
187
  createDevice,
187
188
  createDeviceDownlink,
@@ -198,5 +199,6 @@ export const skiKrumb = (options = {
198
199
  readDeviceDailyDistance,
199
200
  readDeviceData,
200
201
  readGateways,
202
+ readShippingRates
201
203
  };
202
204
  };
package/dist/models.d.ts CHANGED
@@ -55,3 +55,45 @@ export interface QueryDevice {
55
55
  page?: string;
56
56
  timeZone?: string;
57
57
  }
58
+ export interface Amount {
59
+ value: string;
60
+ currency: string;
61
+ }
62
+ export interface Surcharge {
63
+ type: string;
64
+ amount: Amount;
65
+ }
66
+ export interface Tax {
67
+ type: string;
68
+ amount: Amount;
69
+ }
70
+ export interface ValidUntil {
71
+ year: number;
72
+ month: number;
73
+ day: number;
74
+ }
75
+ export interface Rates {
76
+ service_id: string;
77
+ valid_until: ValidUntil;
78
+ total: Amount;
79
+ base: Amount;
80
+ surcharges: Surcharge[];
81
+ taxes: Tax[];
82
+ transit_time_days: number;
83
+ transit_time_not_available: boolean;
84
+ carrier_name: string;
85
+ service_name: string;
86
+ }
87
+ export interface Address {
88
+ city: string;
89
+ country: string;
90
+ line1: string;
91
+ postal_code: string;
92
+ state: string;
93
+ }
94
+ export interface RateRequest {
95
+ name: string;
96
+ address: Address;
97
+ email_addresses: string[];
98
+ quantity: number;
99
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skikrumb-api",
3
- "version": "1.3.7",
3
+ "version": "1.3.8",
4
4
  "description": "Wrapper for the skiKrumb API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -18,6 +18,6 @@
18
18
  "prettier-plugin-organize-attributes": "^1.0.0"
19
19
  },
20
20
  "dependencies": {
21
- "ky": "^0.33.3"
21
+ "ky": "^1.7.5"
22
22
  }
23
23
  }
package/tsconfig.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "target": "ES2015",
3
+ "target": "ES2018",
4
4
  "module": "ES2020",
5
5
  "declaration": true,
6
6
  "outDir": "./dist",
@@ -14,4 +14,4 @@
14
14
  "dist",
15
15
  ".idea"
16
16
  ]
17
- }
17
+ }