@tryvital/vital-node 1.1.0 → 1.3.0
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/.vscode/settings.json +3 -0
- package/__tests__/activity.test.ts +18 -0
- package/__tests__/arrange.ts +36 -0
- package/__tests__/body.test.ts +17 -0
- package/__tests__/devices.test.ts +15 -0
- package/__tests__/link.test.ts +15 -0
- package/__tests__/profile.test.ts +15 -0
- package/__tests__/sleep.test.ts +17 -0
- package/__tests__/user.test.ts +37 -0
- package/__tests__/vitals.test.ts +17 -0
- package/__tests__/workouts.test.ts +17 -0
- package/client/Activity.ts +4 -4
- package/client/Body.ts +4 -5
- package/client/Devices.ts +25 -0
- package/client/Link.ts +2 -2
- package/client/Profile.ts +5 -5
- package/client/Provider.ts +17 -0
- package/client/Sleep.ts +8 -5
- package/client/Testkits.ts +28 -4
- package/client/User.ts +19 -10
- package/client/Vitals.ts +10 -10
- package/client/Workouts.ts +4 -4
- package/client/index.ts +1 -0
- package/client/models/body_model.ts +1 -1
- package/client/models/profile_model.ts +1 -1
- package/client/models/provider_models.ts +19 -0
- package/client/models/provider_specific.ts +1 -1
- package/client/models/raw_response.ts +14 -1
- package/client/models/sleep_models.ts +1 -1
- package/client/models/testkit_models.ts +32 -11
- package/client/models/user_models.ts +3 -2
- package/client/models/workout_models.ts +1 -1
- package/dist/client/Activity.d.ts +2 -2
- package/dist/client/Activity.js +4 -4
- package/dist/client/Body.d.ts +2 -2
- package/dist/client/Body.js +4 -4
- package/dist/client/Devices.d.ts +8 -0
- package/dist/client/Devices.js +62 -0
- package/dist/client/Link.d.ts +1 -1
- package/dist/client/Link.js +2 -2
- package/dist/client/Profile.d.ts +2 -2
- package/dist/client/Profile.js +4 -4
- package/dist/client/Provider.d.ts +8 -0
- package/dist/client/Provider.js +60 -0
- package/dist/client/Sleep.d.ts +2 -2
- package/dist/client/Sleep.js +4 -4
- package/dist/client/Testkits.d.ts +6 -3
- package/dist/client/Testkits.js +43 -4
- package/dist/client/User.d.ts +7 -6
- package/dist/client/User.js +21 -8
- package/dist/client/Vitals.d.ts +5 -5
- package/dist/client/Vitals.js +10 -10
- package/dist/client/Workouts.d.ts +2 -2
- package/dist/client/Workouts.js +4 -4
- package/dist/client/index.d.ts +1 -0
- package/dist/client/index.js +3 -1
- package/dist/client/models/body_model.d.ts +1 -1
- package/dist/client/models/profile_model.d.ts +1 -1
- package/dist/client/models/provider_models.d.ts +18 -0
- package/dist/client/models/provider_models.js +15 -0
- package/dist/client/models/provider_specific.d.ts +1 -1
- package/dist/client/models/raw_response.d.ts +11 -0
- package/dist/client/models/sleep_models.d.ts +1 -1
- package/dist/client/models/testkit_models.d.ts +18 -1
- package/dist/client/models/user_models.d.ts +3 -2
- package/dist/client/models/workout_models.d.ts +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +10 -1
- package/dist/lib/config.d.ts +9 -0
- package/dist/lib/config.js +9 -0
- package/dist/lib/models.d.ts +2 -1
- package/index.ts +12 -1
- package/jest.config.js +6 -0
- package/lib/config.ts +9 -0
- package/lib/models.ts +2 -1
- package/package.json +7 -1
- package/tsconfig.json +14 -5
@@ -0,0 +1,18 @@
|
|
1
|
+
import { VitalClient } from "..";
|
2
|
+
import { testClient, testEuClient, getUserId } from "./arrange";
|
3
|
+
|
4
|
+
|
5
|
+
describe('Activity', () => {
|
6
|
+
it.each([
|
7
|
+
["us", testClient],
|
8
|
+
["eu", testEuClient]
|
9
|
+
])('should return activity data %p', async (region: string, client: VitalClient) => {
|
10
|
+
const userId = await getUserId(client)
|
11
|
+
const data = await client.Activity.get(
|
12
|
+
userId,
|
13
|
+
new Date("2020-01-01"),
|
14
|
+
new Date("2022-01-02"),
|
15
|
+
)
|
16
|
+
expect(data.activity.length).toBeGreaterThan(0)
|
17
|
+
});
|
18
|
+
})
|
@@ -0,0 +1,36 @@
|
|
1
|
+
import { VitalClient } from "..";
|
2
|
+
require('dotenv').config({
|
3
|
+
path: '.env'
|
4
|
+
})
|
5
|
+
|
6
|
+
export const testClient = new VitalClient({
|
7
|
+
client_id: process.env.TEST_CLIENT_ID,
|
8
|
+
client_secret: process.env.TEST_CLIENT_SECRET,
|
9
|
+
environment: process.env.TEST_ENVIRONMENT as any,
|
10
|
+
region: "us",
|
11
|
+
});
|
12
|
+
|
13
|
+
export const testEuClient = new VitalClient({
|
14
|
+
client_id: process.env.TEST_EU_CLIENT_ID,
|
15
|
+
client_secret: process.env.TEST_EU_CLIENT_SECRET,
|
16
|
+
environment: "development",
|
17
|
+
region: "eu",
|
18
|
+
});
|
19
|
+
|
20
|
+
export const test_user_id = "test_user_1234";
|
21
|
+
|
22
|
+
export const getUserId = async (client: VitalClient, user_id: string = test_user_id) => {
|
23
|
+
const data = await client.User.resolve(user_id);
|
24
|
+
return data.user_id;
|
25
|
+
}
|
26
|
+
|
27
|
+
export function randomString(length: number): string {
|
28
|
+
var result = '';
|
29
|
+
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
30
|
+
var charactersLength = characters.length;
|
31
|
+
for (var i = 0; i < length; i++) {
|
32
|
+
result += characters.charAt(Math.floor(Math.random() *
|
33
|
+
charactersLength));
|
34
|
+
}
|
35
|
+
return result;
|
36
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { VitalClient } from "..";
|
2
|
+
import { getUserId, testClient, testEuClient } from "./arrange";
|
3
|
+
|
4
|
+
describe('Body', () => {
|
5
|
+
it.each([
|
6
|
+
["us", testClient],
|
7
|
+
["eu", testEuClient]
|
8
|
+
])('should return body data %p', async (region: string, client: VitalClient) => {
|
9
|
+
const userId = await getUserId(client)
|
10
|
+
const data = await client.Body.get(
|
11
|
+
userId,
|
12
|
+
new Date("2021-01-01"),
|
13
|
+
new Date("2022-01-02"),
|
14
|
+
)
|
15
|
+
expect(data.body.length).toBeGreaterThan(0)
|
16
|
+
});
|
17
|
+
})
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import { VitalClient } from "..";
|
2
|
+
import { testClient, testEuClient, getUserId } from "./arrange";
|
3
|
+
|
4
|
+
describe('Devices', () => {
|
5
|
+
it.each([
|
6
|
+
["us", testClient],
|
7
|
+
["eu", testEuClient]
|
8
|
+
])('should return device data %p', async (region: string, client: VitalClient) => {
|
9
|
+
const userId = await getUserId(client)
|
10
|
+
const data = await client.Devices.get_raw(
|
11
|
+
userId,
|
12
|
+
)
|
13
|
+
expect(data.devices.length).toBeGreaterThan(0)
|
14
|
+
});
|
15
|
+
})
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import { VitalClient } from "..";
|
2
|
+
import { getUserId, testClient, testEuClient } from "./arrange";
|
3
|
+
|
4
|
+
describe('Link', () => {
|
5
|
+
it.each([
|
6
|
+
["us", testClient],
|
7
|
+
["eu", testEuClient]
|
8
|
+
])('should create a link token %p', async (region: string, client: VitalClient) => {
|
9
|
+
const userId = await getUserId(client)
|
10
|
+
const data = await client.Link.create(
|
11
|
+
userId,
|
12
|
+
)
|
13
|
+
expect(data.link_token).toBeDefined()
|
14
|
+
});
|
15
|
+
})
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import { VitalClient } from "..";
|
2
|
+
import { testClient, testEuClient, getUserId } from "./arrange";
|
3
|
+
|
4
|
+
describe('Profile', () => {
|
5
|
+
it.each([
|
6
|
+
["us", testClient],
|
7
|
+
["eu", testEuClient]
|
8
|
+
])('should return profile data %p', async (region: string, client: VitalClient) => {
|
9
|
+
const userId = await getUserId(client)
|
10
|
+
const data = await client.Profile.get(
|
11
|
+
userId,
|
12
|
+
)
|
13
|
+
expect(data.user_id).toBe(userId)
|
14
|
+
});
|
15
|
+
})
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { VitalClient } from "..";
|
2
|
+
import { testClient, testEuClient, getUserId } from "./arrange";
|
3
|
+
|
4
|
+
describe('Sleep', () => {
|
5
|
+
it.each([
|
6
|
+
["us", testClient],
|
7
|
+
["eu", testEuClient]
|
8
|
+
])('should return sleep data %p', async (region: string, client: VitalClient) => {
|
9
|
+
const userId = await getUserId(client)
|
10
|
+
const data = await client.Sleep.get(
|
11
|
+
userId,
|
12
|
+
new Date("2021-01-01"),
|
13
|
+
new Date("2022-01-02"),
|
14
|
+
)
|
15
|
+
expect(data.sleep.length).toBeGreaterThan(0)
|
16
|
+
});
|
17
|
+
})
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import { VitalClient } from "..";
|
2
|
+
import { getUserId, randomString, testClient, testEuClient, test_user_id } from "./arrange";
|
3
|
+
|
4
|
+
describe('User', () => {
|
5
|
+
const user_id = randomString(10);
|
6
|
+
it.each([
|
7
|
+
["us", testClient],
|
8
|
+
["eu", testEuClient]
|
9
|
+
])('should create a user %p', async (region: string, client: VitalClient) => {
|
10
|
+
const user = await client.User.create(
|
11
|
+
user_id,
|
12
|
+
)
|
13
|
+
expect(user.client_user_id).toBe(user_id)
|
14
|
+
});
|
15
|
+
|
16
|
+
it.each([
|
17
|
+
testClient,
|
18
|
+
testEuClient
|
19
|
+
])('should find a user', async (client: VitalClient) => {
|
20
|
+
const user = await client.User.resolve(
|
21
|
+
test_user_id,
|
22
|
+
)
|
23
|
+
expect(user.client_user_id).toBe(test_user_id)
|
24
|
+
});
|
25
|
+
|
26
|
+
it.each([
|
27
|
+
testClient,
|
28
|
+
testEuClient
|
29
|
+
])('should delete a user', async (client: VitalClient) => {
|
30
|
+
const userToDelete = await getUserId(client, user_id);
|
31
|
+
const user = await client.User.delete(
|
32
|
+
userToDelete,
|
33
|
+
)
|
34
|
+
expect(user.success).toBe(true)
|
35
|
+
});
|
36
|
+
|
37
|
+
})
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { VitalClient } from "..";
|
2
|
+
import { testClient, testEuClient, getUserId } from "./arrange";
|
3
|
+
|
4
|
+
describe('Vitals', () => {
|
5
|
+
it.each([
|
6
|
+
["us", testClient],
|
7
|
+
["eu", testEuClient]
|
8
|
+
])('should return glucose data %p', async (region: string, client: VitalClient) => {
|
9
|
+
const userId = await getUserId(client)
|
10
|
+
const data = await client.Vitals.glucose(
|
11
|
+
userId,
|
12
|
+
new Date("2021-01-01"),
|
13
|
+
new Date("2022-01-02"),
|
14
|
+
)
|
15
|
+
expect(data.length).toBeGreaterThan(0)
|
16
|
+
});
|
17
|
+
})
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { VitalClient } from "..";
|
2
|
+
import { testClient, testEuClient, getUserId } from "./arrange";
|
3
|
+
|
4
|
+
describe('Workouts', () => {
|
5
|
+
it.each([
|
6
|
+
["us", testClient],
|
7
|
+
["eu", testEuClient]
|
8
|
+
])('should return workout data %p', async (region: string, client: VitalClient) => {
|
9
|
+
const userId = await getUserId(client)
|
10
|
+
const data = await client.Workouts.get(
|
11
|
+
userId,
|
12
|
+
new Date("2021-01-01"),
|
13
|
+
new Date("2022-01-02"),
|
14
|
+
)
|
15
|
+
expect(data.workouts.length).toBeGreaterThan(0)
|
16
|
+
});
|
17
|
+
})
|
package/client/Activity.ts
CHANGED
@@ -11,13 +11,13 @@ export class ActivityApi {
|
|
11
11
|
}
|
12
12
|
|
13
13
|
public async get(
|
14
|
-
|
14
|
+
userId: string,
|
15
15
|
startDate: Date,
|
16
16
|
endDate: Date,
|
17
17
|
provider?: string
|
18
18
|
): Promise<ClientActivityResponse> {
|
19
19
|
const resp = await this.client.get(
|
20
|
-
this.baseURL.concat(`/summary/activity/${
|
20
|
+
this.baseURL.concat(`/summary/activity/${userId}`),
|
21
21
|
{
|
22
22
|
params: { start_date: startDate, end_date: endDate, provider },
|
23
23
|
}
|
@@ -26,13 +26,13 @@ export class ActivityApi {
|
|
26
26
|
}
|
27
27
|
|
28
28
|
public async get_raw(
|
29
|
-
|
29
|
+
userId: string,
|
30
30
|
startDate: Date,
|
31
31
|
endDate: Date,
|
32
32
|
provider?: string
|
33
33
|
): Promise<ClientActivityRawResponse> {
|
34
34
|
const resp = await this.client.get(
|
35
|
-
this.baseURL.concat(`/summary/activity/${
|
35
|
+
this.baseURL.concat(`/summary/activity/${userId}/raw`),
|
36
36
|
{
|
37
37
|
params: { start_date: startDate, end_date: endDate, provider },
|
38
38
|
}
|
package/client/Body.ts
CHANGED
@@ -12,13 +12,13 @@ export class BodyApi {
|
|
12
12
|
}
|
13
13
|
|
14
14
|
public async get(
|
15
|
-
|
15
|
+
userId: string,
|
16
16
|
startDate: Date,
|
17
17
|
endDate: Date,
|
18
18
|
provider?: string
|
19
19
|
): Promise<ClientBodyResponse> {
|
20
20
|
const resp = await this.client.get(
|
21
|
-
this.baseURL.concat(`/summary/body/${
|
21
|
+
this.baseURL.concat(`/summary/body/${userId}`),
|
22
22
|
{
|
23
23
|
params: { start_date: startDate, end_date: endDate, provider },
|
24
24
|
}
|
@@ -26,15 +26,14 @@ export class BodyApi {
|
|
26
26
|
return resp.data;
|
27
27
|
}
|
28
28
|
|
29
|
-
|
30
29
|
public async get_raw(
|
31
|
-
|
30
|
+
userId: string,
|
32
31
|
startDate: Date,
|
33
32
|
endDate: Date,
|
34
33
|
provider?: string
|
35
34
|
): Promise<ClientBodyRawResponse> {
|
36
35
|
const resp = await this.client.get(
|
37
|
-
this.baseURL.concat(`/summary/body/${
|
36
|
+
this.baseURL.concat(`/summary/body/${userId}/raw`),
|
38
37
|
{
|
39
38
|
params: { start_date: startDate, end_date: endDate, provider },
|
40
39
|
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
2
|
+
import { ClientDevicesRawResponse } from './models/raw_response';
|
3
|
+
|
4
|
+
export class DevicesAPI {
|
5
|
+
baseURL: string;
|
6
|
+
client: AxiosInstance;
|
7
|
+
|
8
|
+
constructor(baseURL: string, axios: AxiosInstance) {
|
9
|
+
this.baseURL = baseURL;
|
10
|
+
this.client = axios;
|
11
|
+
}
|
12
|
+
|
13
|
+
public async get_raw(
|
14
|
+
userId: string,
|
15
|
+
provider?: string
|
16
|
+
): Promise<ClientDevicesRawResponse> {
|
17
|
+
const resp = await this.client.get(
|
18
|
+
this.baseURL.concat(`/summary/devices/${userId}/raw`),
|
19
|
+
{
|
20
|
+
params: { provider },
|
21
|
+
}
|
22
|
+
);
|
23
|
+
return resp.data;
|
24
|
+
}
|
25
|
+
}
|
package/client/Link.ts
CHANGED
@@ -17,11 +17,11 @@ export class LinkApi {
|
|
17
17
|
}
|
18
18
|
|
19
19
|
public async create(
|
20
|
-
|
20
|
+
userId: string,
|
21
21
|
provider: string = null
|
22
22
|
): Promise<LinkTokenExchangeResponse> {
|
23
23
|
const resp = await this.client.post(this.baseURL.concat('/link/token/'), {
|
24
|
-
user_key:
|
24
|
+
user_key: userId,
|
25
25
|
provider,
|
26
26
|
});
|
27
27
|
return resp.data;
|
package/client/Profile.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { AxiosInstance } from 'axios';
|
2
|
-
import { ClientFacingProfile
|
2
|
+
import { ClientFacingProfile } from './models/profile_model';
|
3
3
|
import { ClientProfileRawResponse } from './models/raw_response';
|
4
4
|
|
5
5
|
export class ProfileApi {
|
@@ -12,11 +12,11 @@ export class ProfileApi {
|
|
12
12
|
}
|
13
13
|
|
14
14
|
public async get(
|
15
|
-
|
15
|
+
userId: string,
|
16
16
|
provider?: string
|
17
17
|
): Promise<ClientFacingProfile> {
|
18
18
|
const resp = await this.client.get(
|
19
|
-
this.baseURL.concat(`/summary/profile/${
|
19
|
+
this.baseURL.concat(`/summary/profile/${userId}`),
|
20
20
|
{
|
21
21
|
params: { provider },
|
22
22
|
}
|
@@ -25,13 +25,13 @@ export class ProfileApi {
|
|
25
25
|
}
|
26
26
|
|
27
27
|
public async get_raw(
|
28
|
-
|
28
|
+
userId: string,
|
29
29
|
startDate: Date,
|
30
30
|
endDate: Date,
|
31
31
|
provider?: string
|
32
32
|
): Promise<ClientProfileRawResponse> {
|
33
33
|
const resp = await this.client.get(
|
34
|
-
this.baseURL.concat(`/summary/profile/${
|
34
|
+
this.baseURL.concat(`/summary/profile/${userId}/raw`),
|
35
35
|
{
|
36
36
|
params: { start_date: startDate, end_date: endDate, provider },
|
37
37
|
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
2
|
+
import { Provider } from './models/provider_models';
|
3
|
+
|
4
|
+
export class ProviderApi {
|
5
|
+
baseURL: string;
|
6
|
+
client: AxiosInstance;
|
7
|
+
|
8
|
+
constructor(baseURL: string, axios: AxiosInstance) {
|
9
|
+
this.baseURL = baseURL;
|
10
|
+
this.client = axios;
|
11
|
+
}
|
12
|
+
|
13
|
+
public async getSupportedProviders(): Promise<Provider[]> {
|
14
|
+
const resp = await this.client.get(this.baseURL.concat('/providers/'));
|
15
|
+
return resp.data;
|
16
|
+
}
|
17
|
+
}
|
package/client/Sleep.ts
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
import { AxiosInstance } from 'axios';
|
2
|
-
import {
|
2
|
+
import {
|
3
|
+
ClientSleepResponse,
|
4
|
+
ClientSleepStreamResponse,
|
5
|
+
} from './models/sleep_models';
|
3
6
|
import { ClientSleepRawResponse } from './models/raw_response';
|
4
7
|
|
5
8
|
export class SleepApi {
|
@@ -11,13 +14,13 @@ export class SleepApi {
|
|
11
14
|
}
|
12
15
|
|
13
16
|
public async get(
|
14
|
-
|
17
|
+
userId: string,
|
15
18
|
startDate: Date,
|
16
19
|
endDate: Date,
|
17
20
|
provider?: string
|
18
21
|
): Promise<ClientSleepResponse> {
|
19
22
|
const resp = await this.client.get(
|
20
|
-
this.baseURL.concat(`/summary/sleep/${
|
23
|
+
this.baseURL.concat(`/summary/sleep/${userId}`),
|
21
24
|
{
|
22
25
|
params: { start_date: startDate, end_date: endDate, provider },
|
23
26
|
}
|
@@ -33,13 +36,13 @@ export class SleepApi {
|
|
33
36
|
}
|
34
37
|
|
35
38
|
public async get_raw(
|
36
|
-
|
39
|
+
userId: string,
|
37
40
|
startDate: Date,
|
38
41
|
endDate: Date,
|
39
42
|
provider?: string
|
40
43
|
): Promise<ClientSleepRawResponse> {
|
41
44
|
const resp = await this.client.get(
|
42
|
-
this.baseURL.concat(`/summary/sleep/${
|
45
|
+
this.baseURL.concat(`/summary/sleep/${userId}/raw`),
|
43
46
|
{
|
44
47
|
params: { start_date: startDate, end_date: endDate, provider },
|
45
48
|
}
|
package/client/Testkits.ts
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
import { AxiosInstance } from 'axios';
|
2
2
|
import {
|
3
|
+
LabResultsMetadata,
|
4
|
+
LabResultsRaw,
|
3
5
|
Order,
|
4
6
|
OrderRequestResponse,
|
5
7
|
OrderResponse,
|
@@ -23,19 +25,20 @@ export class TestkitsApi {
|
|
23
25
|
|
24
26
|
public async get_orders(
|
25
27
|
startDate: Date,
|
26
|
-
endDate: Date
|
28
|
+
endDate: Date,
|
29
|
+
status?: string[],
|
27
30
|
): Promise<OrderResponse> {
|
28
31
|
const resp = await this.client.get(
|
29
32
|
this.baseURL.concat('/testkit/orders/'),
|
30
33
|
{
|
31
|
-
params: { start_date: startDate, end_date: endDate },
|
34
|
+
params: { start_date: startDate, end_date: endDate, status: status ? status : null},
|
32
35
|
}
|
33
36
|
);
|
34
37
|
return resp.data;
|
35
38
|
}
|
36
39
|
|
37
40
|
public async order(
|
38
|
-
|
41
|
+
userId: string,
|
39
42
|
testkitId: string,
|
40
43
|
patientAddress: PatientAdress,
|
41
44
|
patientDetails: PatientDetails
|
@@ -43,7 +46,7 @@ export class TestkitsApi {
|
|
43
46
|
const resp = await this.client.post(
|
44
47
|
this.baseURL.concat('/testkit/orders'),
|
45
48
|
{
|
46
|
-
user_key:
|
49
|
+
user_key: userId,
|
47
50
|
testkit_id: testkitId,
|
48
51
|
patient_address: patientAddress,
|
49
52
|
patient_details: patientDetails,
|
@@ -59,6 +62,13 @@ export class TestkitsApi {
|
|
59
62
|
return resp.data;
|
60
63
|
}
|
61
64
|
|
65
|
+
public async cancel_order(orderId: string): Promise<OrderRequestResponse> {
|
66
|
+
const resp = await this.client.post(
|
67
|
+
this.baseURL.concat(`/testkit/orders/${orderId}/cancel`)
|
68
|
+
);
|
69
|
+
return resp.data;
|
70
|
+
}
|
71
|
+
|
62
72
|
public async get_results(orderId: string): Promise<string> {
|
63
73
|
const resp = await this.client.get(
|
64
74
|
this.baseURL.concat(`/testkit/orders/${orderId}/results`),
|
@@ -68,4 +78,18 @@ export class TestkitsApi {
|
|
68
78
|
);
|
69
79
|
return resp.data;
|
70
80
|
}
|
81
|
+
|
82
|
+
public async getMetadata(orderId: string): Promise<LabResultsMetadata> {
|
83
|
+
const resp = await this.client.get(
|
84
|
+
this.baseURL.concat(`/testkit/orders/${orderId}/results/metadata`)
|
85
|
+
);
|
86
|
+
return resp.data;
|
87
|
+
}
|
88
|
+
|
89
|
+
public async getRawResults(orderId: string): Promise<LabResultsRaw> {
|
90
|
+
const resp = await this.client.get(
|
91
|
+
this.baseURL.concat(`/testkit/orders/${orderId}/results/raw`)
|
92
|
+
);
|
93
|
+
return resp.data;
|
94
|
+
}
|
71
95
|
}
|
package/client/User.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { AxiosInstance } from 'axios';
|
2
2
|
import {
|
3
|
-
|
3
|
+
UserIdResponse,
|
4
4
|
SuccessResponse,
|
5
5
|
ClientFacingUser,
|
6
6
|
Providers,
|
@@ -15,16 +15,16 @@ export class UserApi {
|
|
15
15
|
this.client = axios;
|
16
16
|
}
|
17
17
|
|
18
|
-
public async create(clientUserId: string): Promise<
|
18
|
+
public async create(clientUserId: string): Promise<UserIdResponse> {
|
19
19
|
const resp = await this.client.post(this.baseURL.concat('/user/key'), {
|
20
20
|
client_user_id: clientUserId,
|
21
21
|
});
|
22
22
|
return resp.data;
|
23
23
|
}
|
24
24
|
|
25
|
-
public async delete(
|
25
|
+
public async delete(userId: string): Promise<SuccessResponse> {
|
26
26
|
const resp = await this.client.delete(
|
27
|
-
this.baseURL.concat(`/user/${
|
27
|
+
this.baseURL.concat(`/user/${userId}`)
|
28
28
|
);
|
29
29
|
return resp.data;
|
30
30
|
}
|
@@ -34,8 +34,8 @@ export class UserApi {
|
|
34
34
|
return resp.data;
|
35
35
|
}
|
36
36
|
|
37
|
-
public async get(
|
38
|
-
const resp = await this.client.get(this.baseURL.concat(`/user/${
|
37
|
+
public async get(userId: string): Promise<ClientFacingUser> {
|
38
|
+
const resp = await this.client.get(this.baseURL.concat(`/user/${userId}`));
|
39
39
|
return resp.data;
|
40
40
|
}
|
41
41
|
|
@@ -46,19 +46,28 @@ export class UserApi {
|
|
46
46
|
return resp.data;
|
47
47
|
}
|
48
48
|
|
49
|
-
public async providers(
|
49
|
+
public async providers(userId: string): Promise<ProvidersResponse> {
|
50
50
|
const resp = await this.client.get(
|
51
|
-
this.baseURL.concat(`/user/providers/${
|
51
|
+
this.baseURL.concat(`/user/providers/${userId}`)
|
52
52
|
);
|
53
53
|
return resp.data;
|
54
54
|
}
|
55
55
|
|
56
56
|
public async deregisterProvider(
|
57
|
-
|
57
|
+
userId: string,
|
58
58
|
provider: Providers
|
59
59
|
): Promise<SuccessResponse> {
|
60
60
|
const resp = await this.client.delete(
|
61
|
-
this.baseURL.concat(`/user/${
|
61
|
+
this.baseURL.concat(`/user/${userId}/${provider}`)
|
62
|
+
);
|
63
|
+
return resp.data;
|
64
|
+
}
|
65
|
+
|
66
|
+
public async refresh(
|
67
|
+
userId: string,
|
68
|
+
): Promise<SuccessResponse> {
|
69
|
+
const resp = await this.client.post(
|
70
|
+
this.baseURL.concat(`/user/refresh/${userId}`)
|
62
71
|
);
|
63
72
|
return resp.data;
|
64
73
|
}
|
package/client/Vitals.ts
CHANGED
@@ -27,13 +27,13 @@ export class VitalsApi {
|
|
27
27
|
|
28
28
|
public async cholesterol(
|
29
29
|
type: 'ldl' | 'total' | 'triglycerides' | 'hdl',
|
30
|
-
|
30
|
+
userId: string,
|
31
31
|
startDate: Date,
|
32
32
|
endDate: Date,
|
33
33
|
provider?: string
|
34
34
|
): Promise<TimeseriesPoint[]> {
|
35
35
|
return this.timeseriesData(
|
36
|
-
|
36
|
+
userId,
|
37
37
|
`cholesterol/${type}`,
|
38
38
|
startDate,
|
39
39
|
endDate,
|
@@ -42,13 +42,13 @@ export class VitalsApi {
|
|
42
42
|
}
|
43
43
|
|
44
44
|
public async glucose(
|
45
|
-
|
45
|
+
userId: string,
|
46
46
|
startDate: Date,
|
47
47
|
endDate: Date,
|
48
48
|
provider?: string
|
49
49
|
): Promise<TimeseriesPoint[]> {
|
50
50
|
return this.timeseriesData(
|
51
|
-
|
51
|
+
userId,
|
52
52
|
'glucose',
|
53
53
|
startDate,
|
54
54
|
endDate,
|
@@ -57,31 +57,31 @@ export class VitalsApi {
|
|
57
57
|
}
|
58
58
|
|
59
59
|
public async ige(
|
60
|
-
|
60
|
+
userId: string,
|
61
61
|
startDate: Date,
|
62
62
|
endDate: Date,
|
63
63
|
provider?: string
|
64
64
|
): Promise<TimeseriesPoint[]> {
|
65
|
-
return this.timeseriesData(
|
65
|
+
return this.timeseriesData(userId, 'ige', startDate, endDate, provider);
|
66
66
|
}
|
67
67
|
|
68
68
|
public async igg(
|
69
|
-
|
69
|
+
userId: string,
|
70
70
|
startDate: Date,
|
71
71
|
endDate: Date,
|
72
72
|
provider?: string
|
73
73
|
): Promise<TimeseriesPoint[]> {
|
74
|
-
return this.timeseriesData(
|
74
|
+
return this.timeseriesData(userId, 'igg', startDate, endDate, provider);
|
75
75
|
}
|
76
76
|
|
77
77
|
public async heartrate(
|
78
|
-
|
78
|
+
userId: string,
|
79
79
|
startDate: Date,
|
80
80
|
endDate: Date,
|
81
81
|
provider?: string
|
82
82
|
): Promise<TimeseriesPoint[]> {
|
83
83
|
return this.timeseriesData(
|
84
|
-
|
84
|
+
userId,
|
85
85
|
'heartrate',
|
86
86
|
startDate,
|
87
87
|
endDate,
|
package/client/Workouts.ts
CHANGED
@@ -14,13 +14,13 @@ export class WorkoutsApi {
|
|
14
14
|
}
|
15
15
|
|
16
16
|
public async get(
|
17
|
-
|
17
|
+
userId: string,
|
18
18
|
startDate: Date,
|
19
19
|
endDate: Date,
|
20
20
|
provider?: string
|
21
21
|
): Promise<ClientWorkoutResponse> {
|
22
22
|
const resp = await this.client.get(
|
23
|
-
this.baseURL.concat(`/summary/workouts/${
|
23
|
+
this.baseURL.concat(`/summary/workouts/${userId}`),
|
24
24
|
{
|
25
25
|
params: { start_date: startDate, end_date: endDate, provider },
|
26
26
|
}
|
@@ -38,13 +38,13 @@ export class WorkoutsApi {
|
|
38
38
|
}
|
39
39
|
|
40
40
|
public async get_raw(
|
41
|
-
|
41
|
+
userId: string,
|
42
42
|
startDate: Date,
|
43
43
|
endDate: Date,
|
44
44
|
provider?: string
|
45
45
|
): Promise<ClientWorkoutsRawResponse> {
|
46
46
|
const resp = await this.client.get(
|
47
|
-
this.baseURL.concat(`/summary/workouts/${
|
47
|
+
this.baseURL.concat(`/summary/workouts/${userId}/raw`),
|
48
48
|
{
|
49
49
|
params: { start_date: startDate, end_date: endDate, provider },
|
50
50
|
}
|
package/client/index.ts
CHANGED