skikrumb-api 1.3.8 → 1.3.9

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, RateRequest, Rates } from './models';
1
+ import { apiKeys, Device, Gateways, QueryDevice } from './models';
2
2
  export declare const skiKrumb: (options?: {
3
3
  apiKey: string;
4
4
  supabaseToken: string;
@@ -7,6 +7,7 @@ export declare const skiKrumb: (options?: {
7
7
  }) => {
8
8
  createDevice: (deveui: string, serialNumber: string) => Promise<any>;
9
9
  createDeviceDownlink: (userId: string, deveui: string, type?: string) => Promise<any>;
10
+ sendMobileLocation: (payload: any) => Promise<any>;
10
11
  createPaymentIntent: (form: any) => Promise<any>;
11
12
  createPrePurchaseIntent: (form: any) => Promise<any>;
12
13
  getPaymentIntent: (clientSecret: string) => Promise<any>;
@@ -24,5 +25,4 @@ export declare const skiKrumb: (options?: {
24
25
  readDeviceDailyDistance: (serialNumber: string, query: QueryDevice) => Promise<Device[]>;
25
26
  readDeviceData: (serialNumber: string, query: QueryDevice) => Promise<Device>;
26
27
  readGateways: () => Promise<Gateways>;
27
- readShippingRates: (payload: RateRequest) => Promise<Rates[]>;
28
28
  };
package/dist/index.js CHANGED
@@ -1,3 +1,12 @@
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
+ };
1
10
  import ky from 'ky';
2
11
  export const skiKrumb = (options = {
3
12
  apiKey: '',
@@ -19,10 +28,10 @@ export const skiKrumb = (options = {
19
28
  ],
20
29
  },
21
30
  });
22
- const createDevice = async (deveui, serialNumber) => {
31
+ const createDevice = (deveui, serialNumber) => __awaiter(void 0, void 0, void 0, function* () {
23
32
  if (!deveui || !serialNumber)
24
33
  throw new Error('Must pass Lora MAC (deveui) and Serial Number');
25
- return await api
34
+ return yield api
26
35
  .post(`${options.url}/devices`, {
27
36
  headers: {
28
37
  'content-type': 'application/json',
@@ -30,8 +39,8 @@ export const skiKrumb = (options = {
30
39
  json: { deveui: deveui, serial_number: serialNumber },
31
40
  })
32
41
  .json();
33
- };
34
- const createDeviceDownlink = async (userId, deveui, type = 'beep') => {
42
+ });
43
+ const createDeviceDownlink = (userId, deveui, type = 'beep') => __awaiter(void 0, void 0, void 0, function* () {
35
44
  if (!userId || !deveui || !type)
36
45
  throw new Error('Must pass userId, Lora MAC (deveui) and message type');
37
46
  let message = 'DAgAC04zKE9EPTEwKQ0K';
@@ -40,7 +49,7 @@ export const skiKrumb = (options = {
40
49
  message = 'DBECAAAAAAAAAAAB';
41
50
  break;
42
51
  }
43
- return await api
52
+ return yield api
44
53
  .post(`${options.url}/devices/downlink`, {
45
54
  headers: {
46
55
  'content-type': 'application/json',
@@ -57,8 +66,20 @@ export const skiKrumb = (options = {
57
66
  },
58
67
  })
59
68
  .json();
60
- };
61
- const createPaymentIntent = async (form) => {
69
+ });
70
+ const sendMobileLocation = (payload) => __awaiter(void 0, void 0, void 0, function* () {
71
+ if (!payload)
72
+ throw new Error('Payload is required');
73
+ return yield api
74
+ .post(`${options.url}/devices/location/mobile`, {
75
+ headers: {
76
+ 'content-type': 'application/json',
77
+ },
78
+ json: payload,
79
+ })
80
+ .json();
81
+ });
82
+ const createPaymentIntent = (form) => __awaiter(void 0, void 0, void 0, function* () {
62
83
  if (!form)
63
84
  throw new Error('Form values not posted.');
64
85
  return api
@@ -66,13 +87,13 @@ export const skiKrumb = (options = {
66
87
  body: form,
67
88
  })
68
89
  .json();
69
- };
70
- const getPaymentIntent = async (clientSecret) => {
90
+ });
91
+ const getPaymentIntent = (clientSecret) => __awaiter(void 0, void 0, void 0, function* () {
71
92
  if (!clientSecret)
72
93
  throw new Error('Client secret is required');
73
94
  return api.get(`${options.url}/payments/intent/${clientSecret}`).json();
74
- };
75
- const createPrePurchaseIntent = async (form) => {
95
+ });
96
+ const createPrePurchaseIntent = (form) => __awaiter(void 0, void 0, void 0, function* () {
76
97
  if (!form)
77
98
  throw new Error('Form values not posted.');
78
99
  return api
@@ -80,8 +101,8 @@ export const skiKrumb = (options = {
80
101
  body: form,
81
102
  })
82
103
  .json();
83
- };
84
- const updateCustomerAddress = async (customerId, email, shipping) => {
104
+ });
105
+ const updateCustomerAddress = (customerId, email, shipping) => __awaiter(void 0, void 0, void 0, function* () {
85
106
  if (!customerId || !email || !shipping) {
86
107
  throw new Error('Customer ID, email, and shipping details are required');
87
108
  }
@@ -90,8 +111,8 @@ export const skiKrumb = (options = {
90
111
  json: { customerId, email, shipping },
91
112
  })
92
113
  .json();
93
- };
94
- const getTaxCalculation = async (amount, reference, quantity, address) => {
114
+ });
115
+ const getTaxCalculation = (amount, reference, quantity, address) => __awaiter(void 0, void 0, void 0, function* () {
95
116
  if (!amount || !reference || !quantity || !address) {
96
117
  throw new Error('Amount, reference, quantity, and address are required');
97
118
  }
@@ -100,8 +121,8 @@ export const skiKrumb = (options = {
100
121
  json: { amount, reference, quantity, address },
101
122
  })
102
123
  .json();
103
- };
104
- const createSubscription = async (customerId, priceId, cartId, productId, registrations) => {
124
+ });
125
+ const createSubscription = (customerId, priceId, cartId, productId, registrations) => __awaiter(void 0, void 0, void 0, function* () {
105
126
  if (!customerId || !priceId || !cartId || !productId || !registrations) {
106
127
  throw new Error('Customer ID, price Id, cart ID, product ID, and registrations are required');
107
128
  }
@@ -117,8 +138,8 @@ export const skiKrumb = (options = {
117
138
  },
118
139
  })
119
140
  .json();
120
- };
121
- const updateSubscription = async (subscriptionId, quantity, registrations) => {
141
+ });
142
+ const updateSubscription = (subscriptionId, quantity, registrations) => __awaiter(void 0, void 0, void 0, function* () {
122
143
  if (!subscriptionId) {
123
144
  throw new Error('Subscription ID is required');
124
145
  }
@@ -131,61 +152,52 @@ export const skiKrumb = (options = {
131
152
  },
132
153
  })
133
154
  .json();
134
- };
135
- const cancelSubscription = async (subscriptionId) => {
155
+ });
156
+ const cancelSubscription = (subscriptionId) => __awaiter(void 0, void 0, void 0, function* () {
136
157
  if (!subscriptionId) {
137
158
  throw new Error('Subscription ID is required');
138
159
  }
139
160
  return api
140
161
  .delete(`${options.url}/payments/subscription/${subscriptionId}`)
141
162
  .json();
142
- };
143
- const readDeviceData = async (serialNumber, query) => {
163
+ });
164
+ const readDeviceData = (serialNumber, query) => __awaiter(void 0, void 0, void 0, function* () {
144
165
  if (!serialNumber)
145
166
  throw new Error('Serial number is required');
146
167
  return api
147
168
  .get(`${options.url}/devices/data/${serialNumber}`, {
148
- searchParams: new URLSearchParams({ ...query }),
169
+ searchParams: new URLSearchParams(Object.assign({}, query)),
149
170
  })
150
171
  .json();
151
- };
152
- const readGateways = async () => {
172
+ });
173
+ const readGateways = () => __awaiter(void 0, void 0, void 0, function* () {
153
174
  return api.get(`${options.url}/gateways`).json();
154
- };
155
- const readDeviceDailyDistance = async (serialNumber, query) => {
175
+ });
176
+ const readDeviceDailyDistance = (serialNumber, query) => __awaiter(void 0, void 0, void 0, function* () {
156
177
  if (!serialNumber)
157
178
  throw new Error('Serial number is required');
158
179
  return api
159
180
  .get(`${options.url}/devices/${serialNumber}/distance`, {
160
- searchParams: new URLSearchParams({ ...query }),
181
+ searchParams: new URLSearchParams(Object.assign({}, query)),
161
182
  })
162
183
  .json();
163
- };
164
- const readDataForDevices = async (query) => {
184
+ });
185
+ const readDataForDevices = (query) => __awaiter(void 0, void 0, void 0, function* () {
165
186
  if (!query.serial_numbers)
166
187
  throw new Error('Serial number is required');
167
188
  return api
168
189
  .get(`${options.url}/devices/data`, {
169
- searchParams: new URLSearchParams({ ...query }),
190
+ searchParams: new URLSearchParams(Object.assign({}, query)),
170
191
  })
171
192
  .json();
172
- };
173
- const readApiKeys = async () => {
193
+ });
194
+ const readApiKeys = () => __awaiter(void 0, void 0, void 0, function* () {
174
195
  return api.get(`${options.url}/keys`).json();
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
- };
196
+ });
186
197
  return {
187
198
  createDevice,
188
199
  createDeviceDownlink,
200
+ sendMobileLocation,
189
201
  createPaymentIntent,
190
202
  createPrePurchaseIntent,
191
203
  getPaymentIntent,
@@ -199,6 +211,5 @@ export const skiKrumb = (options = {
199
211
  readDeviceDailyDistance,
200
212
  readDeviceData,
201
213
  readGateways,
202
- readShippingRates
203
214
  };
204
215
  };
package/dist/models.d.ts CHANGED
@@ -55,45 +55,3 @@ 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.8",
3
+ "version": "1.3.9",
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": "^1.7.5"
21
+ "ky": "^0.33.3"
22
22
  }
23
23
  }
package/tsconfig.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "target": "ES2018",
3
+ "target": "ES2015",
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
+ }