@tryvital/vital-node 1.3.1 → 1.3.2

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.
@@ -14,4 +14,18 @@ describe('Sleep', () => {
14
14
  )
15
15
  expect(data.sleep.length).toBeGreaterThan(0)
16
16
  });
17
+
18
+ it.each([
19
+ ["us", testClient],
20
+ ["eu", testEuClient]
21
+ ])('should return sleep data %p', async (region: string, client: VitalClient) => {
22
+ const userId = await getUserId(client)
23
+ const data = await client.Sleep.getSleepWithStream(
24
+ userId,
25
+ new Date("2021-01-01"),
26
+ new Date("2022-01-02"),
27
+ )
28
+ expect(data.sleep.length).toBeGreaterThan(0)
29
+ expect(data.sleep[0].sleep_stream).toBeDefined()
30
+ });
17
31
  })
package/client/Sleep.ts CHANGED
@@ -29,6 +29,21 @@ export class SleepApi {
29
29
  return resp.data;
30
30
  }
31
31
 
32
+ public async getSleepWithStream(
33
+ userId: string,
34
+ startDate: Date,
35
+ endDate?: Date,
36
+ provider?: string
37
+ ): Promise<ClientSleepResponse> {
38
+ const resp = await this.client.get(
39
+ this.baseURL.concat(`/summary/sleep/${userId}/stream`),
40
+ {
41
+ params: { start_date: startDate, end_date: endDate, provider },
42
+ }
43
+ );
44
+ return resp.data;
45
+ }
46
+
32
47
  public async getStream(sleepId: string): Promise<ClientSleepStreamResponse> {
33
48
  const resp = await this.client.get(
34
49
  this.baseURL.concat(`/timeseries/sleep/${sleepId}/stream`)
@@ -127,6 +127,13 @@ export interface ClientFacingSleep {
127
127
  * @memberof ClientFacingSleep
128
128
  */
129
129
  user_id: string;
130
+ /**
131
+ * UTC time when the sleep period started
132
+ * @type {ClientSleepStreamResponse}
133
+ * @memberof ClientFacingSleep
134
+ *
135
+ */
136
+ sleep_stream: ClientSleepStreamResponse[];
130
137
  }
131
138
 
132
139
  export interface ClientSleepResponse {
@@ -6,6 +6,7 @@ export declare class SleepApi {
6
6
  client: AxiosInstance;
7
7
  constructor(baseURL: string, axios: AxiosInstance);
8
8
  get(userId: string, startDate: Date, endDate?: Date, provider?: string, with_stream?: boolean): Promise<ClientSleepResponse>;
9
+ getSleepWithStream(userId: string, startDate: Date, endDate?: Date, provider?: string): Promise<ClientSleepResponse>;
9
10
  getStream(sleepId: string): Promise<ClientSleepStreamResponse>;
10
11
  get_raw(userId: string, startDate: Date, endDate?: Date, provider?: string): Promise<ClientSleepRawResponse>;
11
12
  }
@@ -58,6 +58,21 @@ var SleepApi = /** @class */ (function () {
58
58
  });
59
59
  });
60
60
  };
61
+ SleepApi.prototype.getSleepWithStream = function (userId, startDate, endDate, provider) {
62
+ return __awaiter(this, void 0, void 0, function () {
63
+ var resp;
64
+ return __generator(this, function (_a) {
65
+ switch (_a.label) {
66
+ case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/summary/sleep/" + userId + "/stream"), {
67
+ params: { start_date: startDate, end_date: endDate, provider: provider },
68
+ })];
69
+ case 1:
70
+ resp = _a.sent();
71
+ return [2 /*return*/, resp.data];
72
+ }
73
+ });
74
+ });
75
+ };
61
76
  SleepApi.prototype.getStream = function (sleepId) {
62
77
  return __awaiter(this, void 0, void 0, function () {
63
78
  var resp;
@@ -126,6 +126,13 @@ export interface ClientFacingSleep {
126
126
  * @memberof ClientFacingSleep
127
127
  */
128
128
  user_id: string;
129
+ /**
130
+ * UTC time when the sleep period started
131
+ * @type {ClientSleepStreamResponse}
132
+ * @memberof ClientFacingSleep
133
+ *
134
+ */
135
+ sleep_stream: ClientSleepStreamResponse[];
129
136
  }
130
137
  export interface ClientSleepResponse {
131
138
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryvital/vital-node",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "description": "Node client for Vital",
5
5
  "author": "maitham",
6
6
  "keywords": [