skikrumb-api 1.0.5 → 1.0.7
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 +2 -2
- package/dist/models.d.ts +1 -1
- package/package.json +1 -1
- package/{README.md → readme.md} +25 -3
- package/index.ts +0 -77
- package/models.ts +0 -41
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { apiKeys, Device, QueryDevice } from "./models";
|
|
2
2
|
export declare const skiKrumb: (options?: {
|
|
3
3
|
apiKey: string;
|
|
4
|
-
requestedWith: string;
|
|
5
|
-
url: string;
|
|
4
|
+
requestedWith: string | undefined;
|
|
5
|
+
url: string | undefined;
|
|
6
6
|
}) => {
|
|
7
7
|
createPaymentIntent: (form: any) => Promise<any>;
|
|
8
8
|
createPrePurchaseIntent: (form: any) => Promise<any>;
|
package/dist/models.d.ts
CHANGED
package/package.json
CHANGED
package/{README.md → readme.md}
RENAMED
|
@@ -21,6 +21,30 @@ const {readDeviceData} = skiKrumb({
|
|
|
21
21
|
url: 'Defaults to http://api.skikrumb.ca'
|
|
22
22
|
})
|
|
23
23
|
```
|
|
24
|
+
### skiKrumb(options?)
|
|
25
|
+
#### options
|
|
26
|
+
|
|
27
|
+
Type: `object`
|
|
28
|
+
|
|
29
|
+
##### apiKey
|
|
30
|
+
|
|
31
|
+
Type: `string`
|
|
32
|
+
|
|
33
|
+
Your API Key as provided by skiKrumb.
|
|
34
|
+
|
|
35
|
+
##### requestedWith
|
|
36
|
+
|
|
37
|
+
Type: `string`\
|
|
38
|
+
Default: `'skiKrumb API Wrapper'`
|
|
39
|
+
|
|
40
|
+
Sets the `requestedWith` header. Helps with identifying your application.
|
|
41
|
+
|
|
42
|
+
##### url
|
|
43
|
+
|
|
44
|
+
Type: `string`\
|
|
45
|
+
Default: `'https://api.skikrumb.ca'`
|
|
46
|
+
|
|
47
|
+
Defaults to production skiKrumb API URL. Possible values: `https://api-dev.skikrumb.ca` or localhost testing.
|
|
24
48
|
|
|
25
49
|
## API Documentation
|
|
26
50
|
#### [Swagger Documentation](https://api.skikrumb.ca/documentation/static/index.html)
|
|
@@ -28,6 +52,4 @@ const {readDeviceData} = skiKrumb({
|
|
|
28
52
|
> Requires an API key. Request an API Key by emailing info@skikrumb.ca
|
|
29
53
|
|
|
30
54
|
> © skiKrumb
|
|
31
|
-
> `2023`
|
|
32
|
-
|
|
33
|
-
|
|
55
|
+
> `2023`
|
package/index.ts
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import ky from 'ky';
|
|
2
|
-
import {apiKeys, Device, QueryDevice} from "./models";
|
|
3
|
-
|
|
4
|
-
export const skiKrumb = (options = {
|
|
5
|
-
apiKey: '',
|
|
6
|
-
requestedWith: 'skiKrumb API Wrapper',
|
|
7
|
-
url: 'https://api.skikrumb.ca'
|
|
8
|
-
}) => {
|
|
9
|
-
const api = ky.extend({
|
|
10
|
-
hooks: {
|
|
11
|
-
beforeRequest: [
|
|
12
|
-
request => {
|
|
13
|
-
request.headers.set('X-Requested-With', `${options.requestedWith}`)
|
|
14
|
-
request.headers.set('Authorization', `Bearer ${options.apiKey}`)
|
|
15
|
-
request.headers.set('Content-Type', `application/json`)
|
|
16
|
-
}
|
|
17
|
-
]
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
const createPaymentIntent = async (form: any): Promise<any> => {
|
|
22
|
-
if (!form)
|
|
23
|
-
throw new Error('Form values not posted.')
|
|
24
|
-
|
|
25
|
-
return api.post(`${options.url}/payments/intent`, {
|
|
26
|
-
body: form
|
|
27
|
-
}).json()
|
|
28
|
-
}
|
|
29
|
-
const createPrePurchaseIntent = async (form: any): Promise<any> => {
|
|
30
|
-
if (!form)
|
|
31
|
-
throw new Error('Form values not posted.')
|
|
32
|
-
|
|
33
|
-
return api.post(`${options.url}/payments/pre-purchase/intent`, {
|
|
34
|
-
body: form
|
|
35
|
-
}).json()
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const readDeviceData = async (serialNumber: number, query: QueryDevice): Promise<Device[]> => {
|
|
39
|
-
if (!serialNumber)
|
|
40
|
-
throw new Error('Serial number is required')
|
|
41
|
-
|
|
42
|
-
return api.get(`${options.url}/devices/data/${serialNumber}`, {
|
|
43
|
-
searchParams: new URLSearchParams({...query})
|
|
44
|
-
}).json()
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const readDeviceDailyDistance = async (serialNumber: number, query: QueryDevice): Promise<Device[]> => {
|
|
48
|
-
if (!serialNumber)
|
|
49
|
-
throw new Error('Serial number is required')
|
|
50
|
-
|
|
51
|
-
return api.get(`${options.url}/devices/${serialNumber}/distance`, {
|
|
52
|
-
searchParams: new URLSearchParams({...query})
|
|
53
|
-
}).json()
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const readDataForDevices = async (query: QueryDevice): Promise<Device[]> => {
|
|
57
|
-
if (!query.serial_numbers)
|
|
58
|
-
throw new Error('Serial number is required')
|
|
59
|
-
|
|
60
|
-
return api.get(`${options.url}/devices/data`, {
|
|
61
|
-
searchParams: new URLSearchParams({...query})
|
|
62
|
-
}).json()
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const readApiKeys = async (): Promise<apiKeys[]> => {
|
|
66
|
-
return api.get(`${options.url}/keys`).json()
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return {
|
|
70
|
-
createPaymentIntent,
|
|
71
|
-
createPrePurchaseIntent,
|
|
72
|
-
readApiKeys,
|
|
73
|
-
readDataForDevices,
|
|
74
|
-
readDeviceDailyDistance,
|
|
75
|
-
readDeviceData
|
|
76
|
-
};
|
|
77
|
-
};
|
package/models.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
export interface apiKeys {
|
|
2
|
-
id: number;
|
|
3
|
-
name: string;
|
|
4
|
-
description: string;
|
|
5
|
-
jwt: string;
|
|
6
|
-
claims: any;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export interface Device {
|
|
10
|
-
serial_number: number;
|
|
11
|
-
created_at: string;
|
|
12
|
-
updated_at: string;
|
|
13
|
-
data?: Data[];
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface Data {
|
|
17
|
-
latitude: number;
|
|
18
|
-
longitude: number;
|
|
19
|
-
temperature: number;
|
|
20
|
-
battery: number;
|
|
21
|
-
serial_number: number;
|
|
22
|
-
id: number;
|
|
23
|
-
created_at: string;
|
|
24
|
-
updated_at: string;
|
|
25
|
-
recorded_at: string;
|
|
26
|
-
firmware: string;
|
|
27
|
-
signal_strength: number;
|
|
28
|
-
altitude: number;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export interface QueryDevice {
|
|
32
|
-
serial_numbers?: string;
|
|
33
|
-
order_by?: string;
|
|
34
|
-
ascending?: string;
|
|
35
|
-
start_date?: string;
|
|
36
|
-
date?: string;
|
|
37
|
-
end_date?: string;
|
|
38
|
-
size?: string;
|
|
39
|
-
page?: string;
|
|
40
|
-
}
|
|
41
|
-
|