@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.
Files changed (77) hide show
  1. package/.vscode/settings.json +3 -0
  2. package/__tests__/activity.test.ts +18 -0
  3. package/__tests__/arrange.ts +36 -0
  4. package/__tests__/body.test.ts +17 -0
  5. package/__tests__/devices.test.ts +15 -0
  6. package/__tests__/link.test.ts +15 -0
  7. package/__tests__/profile.test.ts +15 -0
  8. package/__tests__/sleep.test.ts +17 -0
  9. package/__tests__/user.test.ts +37 -0
  10. package/__tests__/vitals.test.ts +17 -0
  11. package/__tests__/workouts.test.ts +17 -0
  12. package/client/Activity.ts +4 -4
  13. package/client/Body.ts +4 -5
  14. package/client/Devices.ts +25 -0
  15. package/client/Link.ts +2 -2
  16. package/client/Profile.ts +5 -5
  17. package/client/Provider.ts +17 -0
  18. package/client/Sleep.ts +8 -5
  19. package/client/Testkits.ts +28 -4
  20. package/client/User.ts +19 -10
  21. package/client/Vitals.ts +10 -10
  22. package/client/Workouts.ts +4 -4
  23. package/client/index.ts +1 -0
  24. package/client/models/body_model.ts +1 -1
  25. package/client/models/profile_model.ts +1 -1
  26. package/client/models/provider_models.ts +19 -0
  27. package/client/models/provider_specific.ts +1 -1
  28. package/client/models/raw_response.ts +14 -1
  29. package/client/models/sleep_models.ts +1 -1
  30. package/client/models/testkit_models.ts +32 -11
  31. package/client/models/user_models.ts +3 -2
  32. package/client/models/workout_models.ts +1 -1
  33. package/dist/client/Activity.d.ts +2 -2
  34. package/dist/client/Activity.js +4 -4
  35. package/dist/client/Body.d.ts +2 -2
  36. package/dist/client/Body.js +4 -4
  37. package/dist/client/Devices.d.ts +8 -0
  38. package/dist/client/Devices.js +62 -0
  39. package/dist/client/Link.d.ts +1 -1
  40. package/dist/client/Link.js +2 -2
  41. package/dist/client/Profile.d.ts +2 -2
  42. package/dist/client/Profile.js +4 -4
  43. package/dist/client/Provider.d.ts +8 -0
  44. package/dist/client/Provider.js +60 -0
  45. package/dist/client/Sleep.d.ts +2 -2
  46. package/dist/client/Sleep.js +4 -4
  47. package/dist/client/Testkits.d.ts +6 -3
  48. package/dist/client/Testkits.js +43 -4
  49. package/dist/client/User.d.ts +7 -6
  50. package/dist/client/User.js +21 -8
  51. package/dist/client/Vitals.d.ts +5 -5
  52. package/dist/client/Vitals.js +10 -10
  53. package/dist/client/Workouts.d.ts +2 -2
  54. package/dist/client/Workouts.js +4 -4
  55. package/dist/client/index.d.ts +1 -0
  56. package/dist/client/index.js +3 -1
  57. package/dist/client/models/body_model.d.ts +1 -1
  58. package/dist/client/models/profile_model.d.ts +1 -1
  59. package/dist/client/models/provider_models.d.ts +18 -0
  60. package/dist/client/models/provider_models.js +15 -0
  61. package/dist/client/models/provider_specific.d.ts +1 -1
  62. package/dist/client/models/raw_response.d.ts +11 -0
  63. package/dist/client/models/sleep_models.d.ts +1 -1
  64. package/dist/client/models/testkit_models.d.ts +18 -1
  65. package/dist/client/models/user_models.d.ts +3 -2
  66. package/dist/client/models/workout_models.d.ts +1 -1
  67. package/dist/index.d.ts +4 -1
  68. package/dist/index.js +10 -1
  69. package/dist/lib/config.d.ts +9 -0
  70. package/dist/lib/config.js +9 -0
  71. package/dist/lib/models.d.ts +2 -1
  72. package/index.ts +12 -1
  73. package/jest.config.js +6 -0
  74. package/lib/config.ts +9 -0
  75. package/lib/models.ts +2 -1
  76. package/package.json +7 -1
  77. package/tsconfig.json +14 -5
@@ -0,0 +1,3 @@
1
+ {
2
+ "jest.autoEnable": false
3
+ }
@@ -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
+ })
@@ -11,13 +11,13 @@ export class ActivityApi {
11
11
  }
12
12
 
13
13
  public async get(
14
- userKey: string,
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/${userKey}`),
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
- userKey: string,
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/${userKey}/raw`),
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
- userKey: string,
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/${userKey}`),
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
- userKey: string,
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/${userKey}/raw`),
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
- userKey: string,
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: userKey,
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, } from './models/profile_model';
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
- userKey: string,
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/${userKey}`),
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
- userKey: string,
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/${userKey}/raw`),
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 { ClientSleepResponse, ClientSleepStreamResponse } from './models/sleep_models';
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
- userKey: string,
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/${userKey}`),
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
- userKey: string,
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/${userKey}/raw`),
45
+ this.baseURL.concat(`/summary/sleep/${userId}/raw`),
43
46
  {
44
47
  params: { start_date: startDate, end_date: endDate, provider },
45
48
  }
@@ -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
- userKey: string,
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: userKey,
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
- UserKeyResponse,
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<UserKeyResponse> {
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(userKey: string): Promise<SuccessResponse> {
25
+ public async delete(userId: string): Promise<SuccessResponse> {
26
26
  const resp = await this.client.delete(
27
- this.baseURL.concat(`/user/${userKey}`)
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(userKey: string): Promise<ClientFacingUser> {
38
- const resp = await this.client.get(this.baseURL.concat(`/user/${userKey}`));
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(userKey: string): Promise<ProvidersResponse> {
49
+ public async providers(userId: string): Promise<ProvidersResponse> {
50
50
  const resp = await this.client.get(
51
- this.baseURL.concat(`/user/providers/${userKey}`)
51
+ this.baseURL.concat(`/user/providers/${userId}`)
52
52
  );
53
53
  return resp.data;
54
54
  }
55
55
 
56
56
  public async deregisterProvider(
57
- userKey: string,
57
+ userId: string,
58
58
  provider: Providers
59
59
  ): Promise<SuccessResponse> {
60
60
  const resp = await this.client.delete(
61
- this.baseURL.concat(`/user/${userKey}/${provider}`)
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
- userKey: string,
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
- userKey,
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
- userKey: string,
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
- userKey,
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
- userKey: string,
60
+ userId: string,
61
61
  startDate: Date,
62
62
  endDate: Date,
63
63
  provider?: string
64
64
  ): Promise<TimeseriesPoint[]> {
65
- return this.timeseriesData(userKey, 'ige', startDate, endDate, provider);
65
+ return this.timeseriesData(userId, 'ige', startDate, endDate, provider);
66
66
  }
67
67
 
68
68
  public async igg(
69
- userKey: string,
69
+ userId: string,
70
70
  startDate: Date,
71
71
  endDate: Date,
72
72
  provider?: string
73
73
  ): Promise<TimeseriesPoint[]> {
74
- return this.timeseriesData(userKey, 'igg', startDate, endDate, provider);
74
+ return this.timeseriesData(userId, 'igg', startDate, endDate, provider);
75
75
  }
76
76
 
77
77
  public async heartrate(
78
- userKey: string,
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
- userKey,
84
+ userId,
85
85
  'heartrate',
86
86
  startDate,
87
87
  endDate,
@@ -14,13 +14,13 @@ export class WorkoutsApi {
14
14
  }
15
15
 
16
16
  public async get(
17
- userKey: string,
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/${userKey}`),
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
- userKey: string,
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/${userKey}/raw`),
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
@@ -7,3 +7,4 @@ export { WebhooksApi } from './Webhooks';
7
7
  export { WorkoutsApi } from './Workouts';
8
8
  export { TestkitsApi } from './Testkits';
9
9
  export { ProfileApi } from './Profile';
10
+ export { DevicesAPI } from './Devices';