@tryvital/vital-node 0.3.9 → 1.0.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 (135) hide show
  1. package/client/Activity.ts +1 -1
  2. package/client/Body.ts +1 -1
  3. package/client/Profile.ts +25 -0
  4. package/client/Sleep.ts +2 -2
  5. package/client/Testkits.ts +7 -1
  6. package/client/Vitals.ts +45 -45
  7. package/client/Webhooks.ts +7 -58
  8. package/client/Workouts.ts +3 -3
  9. package/client/index.ts +1 -1
  10. package/client/models/activity.ts +7 -0
  11. package/client/models/body_model.ts +0 -18
  12. package/client/models/profile_model.ts +34 -0
  13. package/dist/client/Activity.js +1 -1
  14. package/dist/client/Body.js +1 -1
  15. package/dist/client/Profile.d.ts +8 -0
  16. package/dist/client/{ProviderSpecific.js → Profile.js} +8 -12
  17. package/dist/client/Sleep.js +2 -2
  18. package/dist/client/Testkits.d.ts +1 -0
  19. package/dist/client/Testkits.js +13 -0
  20. package/dist/client/Vitals.d.ts +7 -6
  21. package/dist/client/Vitals.js +16 -41
  22. package/dist/client/Webhooks.d.ts +1 -7
  23. package/dist/client/Webhooks.js +4 -102
  24. package/dist/client/Workouts.d.ts +1 -1
  25. package/dist/client/Workouts.js +3 -3
  26. package/dist/client/index.d.ts +1 -1
  27. package/dist/client/index.js +3 -3
  28. package/dist/client/models/activity.d.ts +6 -0
  29. package/dist/client/models/body_model.d.ts +0 -18
  30. package/dist/client/models/profile_model.d.ts +33 -0
  31. package/dist/{swagger_client/models/client-activity-response.js → client/models/profile_model.js} +0 -0
  32. package/dist/index.d.ts +2 -2
  33. package/dist/index.js +11 -11
  34. package/dist/lib/config.d.ts +0 -1
  35. package/dist/lib/config.js +0 -1
  36. package/index.ts +14 -14
  37. package/lib/config.ts +0 -1
  38. package/package.json +3 -2
  39. package/client/ProviderSpecific.ts +0 -31
  40. package/dist/client/ProviderSpecific.d.ts +0 -8
  41. package/dist/swagger_client/api.d.ts +0 -18
  42. package/dist/swagger_client/api.js +0 -32
  43. package/dist/swagger_client/apis/activity-api.d.ts +0 -86
  44. package/dist/swagger_client/apis/activity-api.js +0 -241
  45. package/dist/swagger_client/apis/body-api.d.ts +0 -86
  46. package/dist/swagger_client/apis/body-api.js +0 -241
  47. package/dist/swagger_client/apis/link-api.d.ts +0 -115
  48. package/dist/swagger_client/apis/link-api.js +0 -310
  49. package/dist/swagger_client/apis/provider-specific-api.d.ts +0 -90
  50. package/dist/swagger_client/apis/provider-specific-api.js +0 -250
  51. package/dist/swagger_client/apis/sleep-api.d.ts +0 -120
  52. package/dist/swagger_client/apis/sleep-api.js +0 -330
  53. package/dist/swagger_client/apis/user-api.d.ts +0 -243
  54. package/dist/swagger_client/apis/user-api.js +0 -657
  55. package/dist/swagger_client/apis/webhooks-api.d.ts +0 -138
  56. package/dist/swagger_client/apis/webhooks-api.js +0 -379
  57. package/dist/swagger_client/apis/workouts-api.d.ts +0 -120
  58. package/dist/swagger_client/apis/workouts-api.js +0 -330
  59. package/dist/swagger_client/base.d.ts +0 -55
  60. package/dist/swagger_client/base.js +0 -67
  61. package/dist/swagger_client/configuration.d.ts +0 -63
  62. package/dist/swagger_client/configuration.js +0 -16
  63. package/dist/swagger_client/index.d.ts +0 -13
  64. package/dist/swagger_client/index.js +0 -27
  65. package/dist/swagger_client/models/client-activity-response.d.ts +0 -24
  66. package/dist/swagger_client/models/client-body-response.d.ts +0 -24
  67. package/dist/swagger_client/models/client-body-response.js +0 -2
  68. package/dist/swagger_client/models/client-facing-activity.d.ts +0 -84
  69. package/dist/swagger_client/models/client-facing-activity.js +0 -2
  70. package/dist/swagger_client/models/client-facing-body.d.ts +0 -72
  71. package/dist/swagger_client/models/client-facing-body.js +0 -2
  72. package/dist/swagger_client/models/client-facing-sleep-stream.d.ts +0 -48
  73. package/dist/swagger_client/models/client-facing-sleep-stream.js +0 -2
  74. package/dist/swagger_client/models/client-facing-sleep.d.ts +0 -138
  75. package/dist/swagger_client/models/client-facing-sleep.js +0 -2
  76. package/dist/swagger_client/models/client-facing-source-specific.d.ts +0 -48
  77. package/dist/swagger_client/models/client-facing-source-specific.js +0 -2
  78. package/dist/swagger_client/models/client-facing-sport.d.ts +0 -30
  79. package/dist/swagger_client/models/client-facing-sport.js +0 -2
  80. package/dist/swagger_client/models/client-facing-stream.d.ts +0 -84
  81. package/dist/swagger_client/models/client-facing-stream.js +0 -2
  82. package/dist/swagger_client/models/client-facing-user.d.ts +0 -48
  83. package/dist/swagger_client/models/client-facing-user.js +0 -2
  84. package/dist/swagger_client/models/client-facing-webhook.d.ts +0 -42
  85. package/dist/swagger_client/models/client-facing-webhook.js +0 -2
  86. package/dist/swagger_client/models/client-facing-workout.d.ts +0 -150
  87. package/dist/swagger_client/models/client-facing-workout.js +0 -2
  88. package/dist/swagger_client/models/client-sleep-response.d.ts +0 -24
  89. package/dist/swagger_client/models/client-sleep-response.js +0 -2
  90. package/dist/swagger_client/models/client-source-specific-response.d.ts +0 -24
  91. package/dist/swagger_client/models/client-source-specific-response.js +0 -2
  92. package/dist/swagger_client/models/client-webhook-response.d.ts +0 -24
  93. package/dist/swagger_client/models/client-webhook-response.js +0 -2
  94. package/dist/swagger_client/models/client-workout-response.d.ts +0 -24
  95. package/dist/swagger_client/models/client-workout-response.js +0 -2
  96. package/dist/swagger_client/models/connected-source-client-facing.d.ts +0 -24
  97. package/dist/swagger_client/models/connected-source-client-facing.js +0 -2
  98. package/dist/swagger_client/models/httpvalidation-error.d.ts +0 -24
  99. package/dist/swagger_client/models/httpvalidation-error.js +0 -2
  100. package/dist/swagger_client/models/index.d.ts +0 -32
  101. package/dist/swagger_client/models/index.js +0 -44
  102. package/dist/swagger_client/models/individual-provider-data.d.ts +0 -30
  103. package/dist/swagger_client/models/individual-provider-data.js +0 -2
  104. package/dist/swagger_client/models/link-token-exchange-response.d.ts +0 -24
  105. package/dist/swagger_client/models/link-token-exchange-response.js +0 -2
  106. package/dist/swagger_client/models/link-token-exchange.d.ts +0 -30
  107. package/dist/swagger_client/models/link-token-exchange.js +0 -2
  108. package/dist/swagger_client/models/password-providers.d.ts +0 -22
  109. package/dist/swagger_client/models/password-providers.js +0 -28
  110. package/dist/swagger_client/models/provider-link-response.d.ts +0 -30
  111. package/dist/swagger_client/models/provider-link-response.js +0 -2
  112. package/dist/swagger_client/models/providers-that-require-password-auth-whoop-renpho-peloton-zwift.d.ts +0 -18
  113. package/dist/swagger_client/models/providers-that-require-password-auth-whoop-renpho-peloton-zwift.js +0 -2
  114. package/dist/swagger_client/models/providers.d.ts +0 -27
  115. package/dist/swagger_client/models/providers.js +0 -33
  116. package/dist/swagger_client/models/source-client-facing.d.ts +0 -36
  117. package/dist/swagger_client/models/source-client-facing.js +0 -2
  118. package/dist/swagger_client/models/user-create.d.ts +0 -24
  119. package/dist/swagger_client/models/user-create.js +0 -2
  120. package/dist/swagger_client/models/user-key-response.d.ts +0 -30
  121. package/dist/swagger_client/models/user-key-response.js +0 -2
  122. package/dist/swagger_client/models/user-success-response.d.ts +0 -24
  123. package/dist/swagger_client/models/user-success-response.js +0 -2
  124. package/dist/swagger_client/models/validation-error.d.ts +0 -36
  125. package/dist/swagger_client/models/validation-error.js +0 -2
  126. package/dist/swagger_client/models/webhook-register.d.ts +0 -36
  127. package/dist/swagger_client/models/webhook-register.js +0 -2
  128. package/dist/swagger_client/models/webhook-type.d.ts +0 -24
  129. package/dist/swagger_client/models/webhook-type.js +0 -30
  130. package/dist/test/data/mock_webhook.d.ts +0 -49
  131. package/dist/test/data/mock_webhook.js +0 -170
  132. package/dist/test/webhook.spec.d.ts +0 -1
  133. package/dist/test/webhook.spec.js +0 -160
  134. package/test/data/mock_webhook.ts +0 -167
  135. package/test/webhook.spec.ts +0 -254
@@ -16,7 +16,7 @@ export class ActivityApi {
16
16
  provider?: string
17
17
  ): Promise<ClientActivityResponse> {
18
18
  const resp = await this.client.get(
19
- this.baseURL.concat(`/activity/${userKey}`),
19
+ this.baseURL.concat(`/summary/activity/${userKey}`),
20
20
  {
21
21
  params: { start_date: startDate, end_date: endDate, provider },
22
22
  }
package/client/Body.ts CHANGED
@@ -17,7 +17,7 @@ export class BodyApi {
17
17
  provider?: string
18
18
  ): Promise<ClientBodyResponse> {
19
19
  const resp = await this.client.get(
20
- this.baseURL.concat(`/body/${userKey}`),
20
+ this.baseURL.concat(`/summary/body/${userKey}`),
21
21
  {
22
22
  params: { start_date: startDate, end_date: endDate, provider },
23
23
  }
@@ -0,0 +1,25 @@
1
+ import { AxiosInstance } from 'axios';
2
+ import { ClientFacingProfile } from './models/profile_model';
3
+
4
+ export class ProfileApi {
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(
14
+ userKey: string,
15
+ provider?: string
16
+ ): Promise<ClientFacingProfile> {
17
+ const resp = await this.client.get(
18
+ this.baseURL.concat(`/summary/profile/${userKey}`),
19
+ {
20
+ params: { provider },
21
+ }
22
+ );
23
+ return resp.data;
24
+ }
25
+ }
package/client/Sleep.ts CHANGED
@@ -16,7 +16,7 @@ export class SleepApi {
16
16
  provider?: string
17
17
  ): Promise<ClientSleepResponse> {
18
18
  const resp = await this.client.get(
19
- this.baseURL.concat(`/sleep/${userKey}`),
19
+ this.baseURL.concat(`/summary/sleep/${userKey}`),
20
20
  {
21
21
  params: { start_date: startDate, end_date: endDate, provider },
22
22
  }
@@ -26,7 +26,7 @@ export class SleepApi {
26
26
 
27
27
  public async getStream(sleepId: string): Promise<ClientSleepResponse> {
28
28
  const resp = await this.client.get(
29
- this.baseURL.concat(`/sleep/${sleepId}/stream/data`)
29
+ this.baseURL.concat(`/timeseries/sleep/${sleepId}/stream`)
30
30
  );
31
31
  return resp.data;
32
32
  }
@@ -1,5 +1,4 @@
1
1
  import { AxiosInstance } from 'axios';
2
- import { signature } from './lib/WebhookVerification';
3
2
  import {
4
3
  Order,
5
4
  OrderRequestResponse,
@@ -59,4 +58,11 @@ export class TestkitsApi {
59
58
  );
60
59
  return resp.data;
61
60
  }
61
+
62
+ public async get_results(orderId: string): Promise<Order> {
63
+ const resp = await this.client.get(
64
+ this.baseURL.concat(`/testkit/orders/${orderId}/results`)
65
+ );
66
+ return resp.data;
67
+ }
62
68
  }
package/client/Vitals.ts CHANGED
@@ -1,11 +1,5 @@
1
1
  import { AxiosInstance } from 'axios';
2
- import {
3
- ClientCholesterolResponse,
4
- ClientGlucoseResponse,
5
- ClientHba1cResponse,
6
- ClientIgeResponse,
7
- ClientIggResponse,
8
- } from './models/activity';
2
+ import { TimeseriesPoint } from './models/activity';
9
3
 
10
4
  export class VitalsApi {
11
5
  baseURL: string;
@@ -15,15 +9,15 @@ export class VitalsApi {
15
9
  this.client = axios;
16
10
  }
17
11
 
18
- public async cholesterol(
19
- type: 'ldl' | 'total_cholesterol' | 'triglycerides' | 'hdl',
20
- userKey: string,
12
+ private async timeseriesData(
13
+ user_key: string,
14
+ resource: string,
21
15
  startDate: Date,
22
16
  endDate: Date,
23
17
  provider?: string
24
- ): Promise<ClientCholesterolResponse> {
18
+ ): Promise<TimeseriesPoint[]> {
25
19
  const resp = await this.client.get(
26
- this.baseURL.concat(`/vitals/cholesterol/${type}/${userKey}`),
20
+ this.baseURL.concat(`/timeseries/${user_key}/${resource}`),
27
21
  {
28
22
  params: { start_date: startDate, end_date: endDate, provider },
29
23
  }
@@ -31,61 +25,67 @@ export class VitalsApi {
31
25
  return resp.data;
32
26
  }
33
27
 
34
- public async glucose(
28
+ public async cholesterol(
29
+ type: 'ldl' | 'total' | 'triglycerides' | 'hdl',
35
30
  userKey: string,
36
31
  startDate: Date,
37
32
  endDate: Date,
38
33
  provider?: string
39
- ): Promise<ClientGlucoseResponse> {
40
- const resp = await this.client.get(
41
- this.baseURL.concat(`/vitals/glucose/${userKey}`),
42
- {
43
- params: { start_date: startDate, end_date: endDate, provider },
44
- }
34
+ ): Promise<TimeseriesPoint[]> {
35
+ return this.timeseriesData(
36
+ userKey,
37
+ `cholesterol/${type}`,
38
+ startDate,
39
+ endDate,
40
+ provider
45
41
  );
46
- return resp.data;
47
42
  }
48
43
 
49
- public async hba1c(
44
+ public async glucose(
50
45
  userKey: string,
51
46
  startDate: Date,
52
47
  endDate: Date,
53
48
  provider?: string
54
- ): Promise<ClientHba1cResponse> {
55
- const resp = await this.client.get(
56
- this.baseURL.concat(`/vitals/hba1c/${userKey}`),
57
- {
58
- params: { start_date: startDate, end_date: endDate, provider },
59
- }
49
+ ): Promise<TimeseriesPoint[]> {
50
+ return this.timeseriesData(
51
+ userKey,
52
+ 'glucose',
53
+ startDate,
54
+ endDate,
55
+ provider
60
56
  );
61
- return resp.data;
62
57
  }
63
58
 
64
59
  public async ige(
65
60
  userKey: string,
66
61
  startDate: Date,
67
- endDate: Date
68
- ): Promise<ClientIgeResponse> {
69
- const resp = await this.client.get(
70
- this.baseURL.concat(`/vitals/ige/${userKey}`),
71
- {
72
- params: { start_date: startDate, end_date: endDate },
73
- }
74
- );
75
- return resp.data;
62
+ endDate: Date,
63
+ provider?: string
64
+ ): Promise<TimeseriesPoint[]> {
65
+ return this.timeseriesData(userKey, 'ige', startDate, endDate, provider);
76
66
  }
77
67
 
78
68
  public async igg(
79
69
  userKey: string,
80
70
  startDate: Date,
81
- endDate: Date
82
- ): Promise<ClientIggResponse> {
83
- const resp = await this.client.get(
84
- this.baseURL.concat(`/vitals/igg/${userKey}`),
85
- {
86
- params: { start_date: startDate, end_date: endDate },
87
- }
71
+ endDate: Date,
72
+ provider?: string
73
+ ): Promise<TimeseriesPoint[]> {
74
+ return this.timeseriesData(userKey, 'igg', startDate, endDate, provider);
75
+ }
76
+
77
+ public async heartrate(
78
+ userKey: string,
79
+ startDate: Date,
80
+ endDate: Date,
81
+ provider?: string
82
+ ): Promise<TimeseriesPoint[]> {
83
+ return this.timeseriesData(
84
+ userKey,
85
+ 'heartrate',
86
+ startDate,
87
+ endDate,
88
+ provider
88
89
  );
89
- return resp.data;
90
90
  }
91
91
  }
@@ -1,71 +1,20 @@
1
1
  import { AxiosInstance } from 'axios';
2
- import { signature } from './lib/WebhookVerification';
3
- import {
4
- ClientWebhookResponse,
5
- WebhookEventTypes,
6
- ClientFacingWebhook,
7
- } from './models/webhook_models';
2
+ import { Webhook } from 'svix';
8
3
 
9
4
  export class WebhooksApi {
10
- DEFAULT_TOLERANCE: number;
11
-
12
5
  baseURL: string;
13
6
  client: AxiosInstance;
14
7
  constructor(baseURL: string, axios: AxiosInstance) {
15
8
  this.baseURL = baseURL;
16
9
  this.client = axios;
17
- this.DEFAULT_TOLERANCE = 300; // 5 minutes
18
- }
19
-
20
- public async getAll(): Promise<ClientWebhookResponse> {
21
- const resp = await this.client.get(this.baseURL.concat('/webhooks/'));
22
- return resp.data;
23
- }
24
-
25
- public async register(
26
- callbackUrl: string,
27
- verifyToken: string,
28
- eventType: WebhookEventTypes
29
- ): Promise<ClientFacingWebhook> {
30
- const resp = await this.client.post(this.baseURL.concat('/webhooks/'), {
31
- callback_url: callbackUrl,
32
- verify_token: verifyToken,
33
- event_type: eventType,
34
- });
35
- return resp.data;
36
- }
37
-
38
- public async deregister(webhookId: string): Promise<ClientFacingWebhook> {
39
- const resp = await this.client.delete(
40
- this.baseURL.concat(`/webhooks/${webhookId}`)
41
- );
42
- return resp.data;
43
- }
44
-
45
- public async test(
46
- event_code: 'HISTORICAL_DATA_UPDATE' | 'CREATED',
47
- webhook_type: 'activity' | 'body' | 'sleep' | 'workouts'
48
- ): Promise<ClientFacingWebhook> {
49
- const resp = await this.client.post(this.baseURL.concat('/webhooks/test'), {
50
- event_code,
51
- webhook_type,
52
- });
53
- return resp.data;
54
10
  }
55
11
 
56
- public constructWebhookEvent(
12
+ public static constructWebhookEvent(
57
13
  payload: string,
58
- header: string,
59
- secret: string,
60
- tolerance: number = undefined
61
- ): Record<string, unknown> {
62
- signature.verifyHeader(
63
- payload,
64
- header,
65
- secret,
66
- tolerance || this.DEFAULT_TOLERANCE
67
- );
68
- const jsonPayload = JSON.parse(payload);
69
- return jsonPayload;
14
+ headers: Record<string, string>,
15
+ secret: string
16
+ ): unknown {
17
+ const wh = new Webhook(secret);
18
+ return wh.verify(payload, headers);
70
19
  }
71
20
  }
@@ -19,7 +19,7 @@ export class WorkoutsApi {
19
19
  provider?: string
20
20
  ): Promise<ClientWorkoutResponse> {
21
21
  const resp = await this.client.get(
22
- this.baseURL.concat(`/workouts/${userKey}`),
22
+ this.baseURL.concat(`/summary/workouts/${userKey}`),
23
23
  {
24
24
  params: { start_date: startDate, end_date: endDate, provider },
25
25
  }
@@ -27,11 +27,11 @@ export class WorkoutsApi {
27
27
  return resp.data;
28
28
  }
29
29
 
30
- public async get_stream(
30
+ public async getStream(
31
31
  workoutId: string
32
32
  ): Promise<ClientWorkoutStreamResponse> {
33
33
  const resp = await this.client.get(
34
- this.baseURL.concat(`/workouts/${workoutId}/stream/data`)
34
+ this.baseURL.concat(`/timeseries/workouts/${workoutId}/stream`)
35
35
  );
36
36
  return resp.data;
37
37
  }
package/client/index.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  export { ActivityApi } from './Activity';
2
2
  export { BodyApi } from './Body';
3
3
  export { LinkApi } from './Link';
4
- export { ProviderSpecificApi } from './ProviderSpecific';
5
4
  export { SleepApi } from './Sleep';
6
5
  export { UserApi } from './User';
7
6
  export { WebhooksApi } from './Webhooks';
8
7
  export { WorkoutsApi } from './Workouts';
9
8
  export { TestkitsApi } from './Testkits';
9
+ export { ProfileApi } from './Profile';
@@ -94,6 +94,13 @@ export interface ClientCholesterolResponse {
94
94
  cholesterol: ClientFacingCholesterol[];
95
95
  }
96
96
 
97
+ export interface TimeseriesPoint {
98
+ timestamp: Date;
99
+ value: number;
100
+ type: string;
101
+ unit: string;
102
+ }
103
+
97
104
  enum RespiratoryAllergen {
98
105
  D_PTERONYSSINUS = 'd_pteronyssinus',
99
106
  D_FARINAE = 'd_farinae',
@@ -30,24 +30,6 @@ export interface ClientFacingBody {
30
30
  * @memberof ClientFacingBody
31
31
  */
32
32
  fat?: number;
33
- /**
34
- * Age of user.::years
35
- * @type {number}
36
- * @memberof ClientFacingBody
37
- */
38
- age?: number;
39
- /**
40
- * Height in cm.::cm
41
- * @type {number}
42
- * @memberof ClientFacingBody
43
- */
44
- height?: number;
45
- /**
46
- * Gender of user.
47
- * @type {string}
48
- * @memberof ClientFacingBody
49
- */
50
- gender?: string;
51
33
  /**
52
34
  * Source the data has come from.
53
35
  * @type {SourceClientFacing}
@@ -0,0 +1,34 @@
1
+ import { SourceClientFacing } from './user_models';
2
+
3
+ export interface ClientFacingProfile {
4
+ /**
5
+ * Age of user.::years
6
+ * @type {number}
7
+ * @memberof ClientFacingBody
8
+ */
9
+ age?: number;
10
+ /**
11
+ * Height in cm.::cm
12
+ * @type {number}
13
+ * @memberof ClientFacingBody
14
+ */
15
+ height?: number;
16
+ /**
17
+ * Gender of user.
18
+ * @type {string}
19
+ * @memberof ClientFacingBody
20
+ */
21
+ gender?: string;
22
+ /**
23
+ * Source the data has come from.
24
+ * @type {SourceClientFacing}
25
+ * @memberof ClientFacingBody
26
+ */
27
+ source: SourceClientFacing;
28
+ /**
29
+ * User key returned by vital create user key request. This key should be stored in your database against the user and used for all interactions with the vital api.
30
+ * @type {string}
31
+ * @memberof ClientFacingBody
32
+ */
33
+ user_id: string;
34
+ }
@@ -47,7 +47,7 @@ var ActivityApi = /** @class */ (function () {
47
47
  var resp;
48
48
  return __generator(this, function (_a) {
49
49
  switch (_a.label) {
50
- case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/activity/" + userKey), {
50
+ case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/summary/activity/" + userKey), {
51
51
  params: { start_date: startDate, end_date: endDate, provider: provider },
52
52
  })];
53
53
  case 1:
@@ -47,7 +47,7 @@ var BodyApi = /** @class */ (function () {
47
47
  var resp;
48
48
  return __generator(this, function (_a) {
49
49
  switch (_a.label) {
50
- case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/body/" + userKey), {
50
+ case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/summary/body/" + userKey), {
51
51
  params: { start_date: startDate, end_date: endDate, provider: provider },
52
52
  })];
53
53
  case 1:
@@ -0,0 +1,8 @@
1
+ import { AxiosInstance } from 'axios';
2
+ import { ClientFacingProfile } from './models/profile_model';
3
+ export declare class ProfileApi {
4
+ baseURL: string;
5
+ client: AxiosInstance;
6
+ constructor(baseURL: string, axios: AxiosInstance);
7
+ get(userKey: string, provider?: string): Promise<ClientFacingProfile>;
8
+ }
@@ -36,23 +36,19 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
36
36
  }
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.ProviderSpecificApi = void 0;
40
- var ProviderSpecificApi = /** @class */ (function () {
41
- function ProviderSpecificApi(baseURL, axios) {
39
+ exports.ProfileApi = void 0;
40
+ var ProfileApi = /** @class */ (function () {
41
+ function ProfileApi(baseURL, axios) {
42
42
  this.baseURL = baseURL;
43
43
  this.client = axios;
44
44
  }
45
- ProviderSpecificApi.prototype.get = function (userKey, startDate, endDate, provider, dataType) {
45
+ ProfileApi.prototype.get = function (userKey, provider) {
46
46
  return __awaiter(this, void 0, void 0, function () {
47
47
  var resp;
48
48
  return __generator(this, function (_a) {
49
49
  switch (_a.label) {
50
- case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/provider-specific/" + userKey + "/" + provider), {
51
- params: {
52
- start_date: startDate,
53
- end_date: endDate,
54
- data_type: dataType,
55
- },
50
+ case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/summary/profile/" + userKey), {
51
+ params: { provider: provider },
56
52
  })];
57
53
  case 1:
58
54
  resp = _a.sent();
@@ -61,6 +57,6 @@ var ProviderSpecificApi = /** @class */ (function () {
61
57
  });
62
58
  });
63
59
  };
64
- return ProviderSpecificApi;
60
+ return ProfileApi;
65
61
  }());
66
- exports.ProviderSpecificApi = ProviderSpecificApi;
62
+ exports.ProfileApi = ProfileApi;
@@ -47,7 +47,7 @@ var SleepApi = /** @class */ (function () {
47
47
  var resp;
48
48
  return __generator(this, function (_a) {
49
49
  switch (_a.label) {
50
- case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/sleep/" + userKey), {
50
+ case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/summary/sleep/" + userKey), {
51
51
  params: { start_date: startDate, end_date: endDate, provider: provider },
52
52
  })];
53
53
  case 1:
@@ -62,7 +62,7 @@ var SleepApi = /** @class */ (function () {
62
62
  var resp;
63
63
  return __generator(this, function (_a) {
64
64
  switch (_a.label) {
65
- case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/sleep/" + sleepId + "/stream/data"))];
65
+ case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/timeseries/sleep/" + sleepId + "/stream"))];
66
66
  case 1:
67
67
  resp = _a.sent();
68
68
  return [2 /*return*/, resp.data];
@@ -8,4 +8,5 @@ export declare class TestkitsApi {
8
8
  get_orders(startDate: Date, endDate: Date): Promise<OrderResponse>;
9
9
  order(userKey: string, testkitId: string, patientAddress: PatientAdress, patientDetails: PatientDetails): Promise<OrderRequestResponse>;
10
10
  get_order(orderId: string): Promise<Order>;
11
+ get_results(orderId: string): Promise<Order>;
11
12
  }
@@ -101,6 +101,19 @@ var TestkitsApi = /** @class */ (function () {
101
101
  });
102
102
  });
103
103
  };
104
+ TestkitsApi.prototype.get_results = function (orderId) {
105
+ return __awaiter(this, void 0, void 0, function () {
106
+ var resp;
107
+ return __generator(this, function (_a) {
108
+ switch (_a.label) {
109
+ case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/testkit/orders/" + orderId + "/results"))];
110
+ case 1:
111
+ resp = _a.sent();
112
+ return [2 /*return*/, resp.data];
113
+ }
114
+ });
115
+ });
116
+ };
104
117
  return TestkitsApi;
105
118
  }());
106
119
  exports.TestkitsApi = TestkitsApi;
@@ -1,12 +1,13 @@
1
1
  import { AxiosInstance } from 'axios';
2
- import { ClientCholesterolResponse, ClientGlucoseResponse, ClientHba1cResponse, ClientIgeResponse, ClientIggResponse } from './models/activity';
2
+ import { TimeseriesPoint } from './models/activity';
3
3
  export declare class VitalsApi {
4
4
  baseURL: string;
5
5
  client: AxiosInstance;
6
6
  constructor(baseURL: string, axios: AxiosInstance);
7
- cholesterol(type: 'ldl' | 'total_cholesterol' | 'triglycerides' | 'hdl', userKey: string, startDate: Date, endDate: Date, provider?: string): Promise<ClientCholesterolResponse>;
8
- glucose(userKey: string, startDate: Date, endDate: Date, provider?: string): Promise<ClientGlucoseResponse>;
9
- hba1c(userKey: string, startDate: Date, endDate: Date, provider?: string): Promise<ClientHba1cResponse>;
10
- ige(userKey: string, startDate: Date, endDate: Date): Promise<ClientIgeResponse>;
11
- igg(userKey: string, startDate: Date, endDate: Date): Promise<ClientIggResponse>;
7
+ private timeseriesData;
8
+ cholesterol(type: 'ldl' | 'total' | 'triglycerides' | 'hdl', userKey: string, startDate: Date, endDate: Date, provider?: string): Promise<TimeseriesPoint[]>;
9
+ glucose(userKey: string, startDate: Date, endDate: Date, provider?: string): Promise<TimeseriesPoint[]>;
10
+ ige(userKey: string, startDate: Date, endDate: Date, provider?: string): Promise<TimeseriesPoint[]>;
11
+ igg(userKey: string, startDate: Date, endDate: Date, provider?: string): Promise<TimeseriesPoint[]>;
12
+ heartrate(userKey: string, startDate: Date, endDate: Date, provider?: string): Promise<TimeseriesPoint[]>;
12
13
  }
@@ -42,12 +42,12 @@ var VitalsApi = /** @class */ (function () {
42
42
  this.baseURL = baseURL;
43
43
  this.client = axios;
44
44
  }
45
- VitalsApi.prototype.cholesterol = function (type, userKey, startDate, endDate, provider) {
45
+ VitalsApi.prototype.timeseriesData = function (user_key, resource, startDate, endDate, provider) {
46
46
  return __awaiter(this, void 0, void 0, function () {
47
47
  var resp;
48
48
  return __generator(this, function (_a) {
49
49
  switch (_a.label) {
50
- case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/vitals/cholesterol/" + type + "/" + userKey), {
50
+ case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/timeseries/" + user_key + "/" + resource), {
51
51
  params: { start_date: startDate, end_date: endDate, provider: provider },
52
52
  })];
53
53
  case 1:
@@ -57,63 +57,38 @@ var VitalsApi = /** @class */ (function () {
57
57
  });
58
58
  });
59
59
  };
60
+ VitalsApi.prototype.cholesterol = function (type, userKey, startDate, endDate, provider) {
61
+ return __awaiter(this, void 0, void 0, function () {
62
+ return __generator(this, function (_a) {
63
+ return [2 /*return*/, this.timeseriesData(userKey, "cholesterol/" + type, startDate, endDate, provider)];
64
+ });
65
+ });
66
+ };
60
67
  VitalsApi.prototype.glucose = function (userKey, startDate, endDate, provider) {
61
68
  return __awaiter(this, void 0, void 0, function () {
62
- var resp;
63
69
  return __generator(this, function (_a) {
64
- switch (_a.label) {
65
- case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/vitals/glucose/" + userKey), {
66
- params: { start_date: startDate, end_date: endDate, provider: provider },
67
- })];
68
- case 1:
69
- resp = _a.sent();
70
- return [2 /*return*/, resp.data];
71
- }
70
+ return [2 /*return*/, this.timeseriesData(userKey, 'glucose', startDate, endDate, provider)];
72
71
  });
73
72
  });
74
73
  };
75
- VitalsApi.prototype.hba1c = function (userKey, startDate, endDate, provider) {
74
+ VitalsApi.prototype.ige = function (userKey, startDate, endDate, provider) {
76
75
  return __awaiter(this, void 0, void 0, function () {
77
- var resp;
78
76
  return __generator(this, function (_a) {
79
- switch (_a.label) {
80
- case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/vitals/hba1c/" + userKey), {
81
- params: { start_date: startDate, end_date: endDate, provider: provider },
82
- })];
83
- case 1:
84
- resp = _a.sent();
85
- return [2 /*return*/, resp.data];
86
- }
77
+ return [2 /*return*/, this.timeseriesData(userKey, 'ige', startDate, endDate, provider)];
87
78
  });
88
79
  });
89
80
  };
90
- VitalsApi.prototype.ige = function (userKey, startDate, endDate) {
81
+ VitalsApi.prototype.igg = function (userKey, startDate, endDate, provider) {
91
82
  return __awaiter(this, void 0, void 0, function () {
92
- var resp;
93
83
  return __generator(this, function (_a) {
94
- switch (_a.label) {
95
- case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/vitals/ige/" + userKey), {
96
- params: { start_date: startDate, end_date: endDate },
97
- })];
98
- case 1:
99
- resp = _a.sent();
100
- return [2 /*return*/, resp.data];
101
- }
84
+ return [2 /*return*/, this.timeseriesData(userKey, 'igg', startDate, endDate, provider)];
102
85
  });
103
86
  });
104
87
  };
105
- VitalsApi.prototype.igg = function (userKey, startDate, endDate) {
88
+ VitalsApi.prototype.heartrate = function (userKey, startDate, endDate, provider) {
106
89
  return __awaiter(this, void 0, void 0, function () {
107
- var resp;
108
90
  return __generator(this, function (_a) {
109
- switch (_a.label) {
110
- case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/vitals/igg/" + userKey), {
111
- params: { start_date: startDate, end_date: endDate },
112
- })];
113
- case 1:
114
- resp = _a.sent();
115
- return [2 /*return*/, resp.data];
116
- }
91
+ return [2 /*return*/, this.timeseriesData(userKey, 'heartrate', startDate, endDate, provider)];
117
92
  });
118
93
  });
119
94
  };
@@ -1,13 +1,7 @@
1
1
  import { AxiosInstance } from 'axios';
2
- import { ClientWebhookResponse, WebhookEventTypes, ClientFacingWebhook } from './models/webhook_models';
3
2
  export declare class WebhooksApi {
4
- DEFAULT_TOLERANCE: number;
5
3
  baseURL: string;
6
4
  client: AxiosInstance;
7
5
  constructor(baseURL: string, axios: AxiosInstance);
8
- getAll(): Promise<ClientWebhookResponse>;
9
- register(callbackUrl: string, verifyToken: string, eventType: WebhookEventTypes): Promise<ClientFacingWebhook>;
10
- deregister(webhookId: string): Promise<ClientFacingWebhook>;
11
- test(event_code: 'HISTORICAL_DATA_UPDATE' | 'CREATED', webhook_type: 'activity' | 'body' | 'sleep' | 'workouts'): Promise<ClientFacingWebhook>;
12
- constructWebhookEvent(payload: string, header: string, secret: string, tolerance?: number): Record<string, unknown>;
6
+ static constructWebhookEvent(payload: string, headers: Record<string, string>, secret: string): unknown;
13
7
  }