@tryvital/vital-node 1.1.1 → 1.3.1

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 (74) hide show
  1. package/.github/workflows/deploy.yaml +11 -50
  2. package/.vscode/settings.json +3 -0
  3. package/__tests__/activity.test.ts +18 -0
  4. package/__tests__/arrange.ts +36 -0
  5. package/__tests__/body.test.ts +17 -0
  6. package/__tests__/devices.test.ts +15 -0
  7. package/__tests__/link.test.ts +15 -0
  8. package/__tests__/profile.test.ts +15 -0
  9. package/__tests__/sleep.test.ts +17 -0
  10. package/__tests__/user.test.ts +37 -0
  11. package/__tests__/vitals.test.ts +17 -0
  12. package/__tests__/workouts.test.ts +17 -0
  13. package/client/Activity.ts +6 -6
  14. package/client/Body.ts +6 -7
  15. package/client/Devices.ts +25 -0
  16. package/client/Link.ts +2 -2
  17. package/client/Profile.ts +5 -5
  18. package/client/Provider.ts +1 -1
  19. package/client/Sleep.ts +13 -9
  20. package/client/Testkits.ts +12 -4
  21. package/client/User.ts +19 -10
  22. package/client/Vitals.ts +16 -16
  23. package/client/Workouts.ts +6 -6
  24. package/client/index.ts +1 -0
  25. package/client/models/body_model.ts +1 -1
  26. package/client/models/profile_model.ts +1 -1
  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 +13 -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.js +1 -1
  44. package/dist/client/Sleep.d.ts +2 -2
  45. package/dist/client/Sleep.js +6 -5
  46. package/dist/client/Testkits.d.ts +3 -2
  47. package/dist/client/Testkits.js +17 -4
  48. package/dist/client/User.d.ts +7 -6
  49. package/dist/client/User.js +21 -8
  50. package/dist/client/Vitals.d.ts +5 -5
  51. package/dist/client/Vitals.js +10 -10
  52. package/dist/client/Workouts.d.ts +2 -2
  53. package/dist/client/Workouts.js +4 -4
  54. package/dist/client/index.d.ts +1 -0
  55. package/dist/client/index.js +3 -1
  56. package/dist/client/models/body_model.d.ts +1 -1
  57. package/dist/client/models/profile_model.d.ts +1 -1
  58. package/dist/client/models/provider_specific.d.ts +1 -1
  59. package/dist/client/models/raw_response.d.ts +11 -0
  60. package/dist/client/models/sleep_models.d.ts +1 -1
  61. package/dist/client/models/testkit_models.d.ts +1 -1
  62. package/dist/client/models/user_models.d.ts +3 -2
  63. package/dist/client/models/workout_models.d.ts +1 -1
  64. package/dist/index.d.ts +2 -1
  65. package/dist/index.js +8 -1
  66. package/dist/lib/config.d.ts +9 -0
  67. package/dist/lib/config.js +9 -0
  68. package/dist/lib/models.d.ts +2 -1
  69. package/index.ts +9 -1
  70. package/jest.config.js +6 -0
  71. package/lib/config.ts +9 -0
  72. package/lib/models.ts +2 -1
  73. package/package.json +7 -1
  74. package/tsconfig.json +14 -5
package/client/Vitals.ts CHANGED
@@ -13,7 +13,7 @@ export class VitalsApi {
13
13
  user_key: string,
14
14
  resource: string,
15
15
  startDate: Date,
16
- endDate: Date,
16
+ endDate?: Date,
17
17
  provider?: string
18
18
  ): Promise<TimeseriesPoint[]> {
19
19
  const resp = await this.client.get(
@@ -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
- endDate: Date,
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
- endDate: Date,
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
- endDate: Date,
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
- endDate: Date,
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
- endDate: Date,
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
- endDate: Date,
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
- endDate: Date,
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';
@@ -37,7 +37,7 @@ export interface ClientFacingBody {
37
37
  */
38
38
  source: SourceClientFacing;
39
39
  /**
40
- * 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.
40
+ * User id returned by vital create user id request. This id should be stored in your database against the user and used for all interactions with the vital api.
41
41
  * @type {string}
42
42
  * @memberof ClientFacingBody
43
43
  */
@@ -26,7 +26,7 @@ export interface ClientFacingProfile {
26
26
  */
27
27
  source: SourceClientFacing;
28
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.
29
+ * User id returned by vital create user id request. This id should be stored in your database against the user and used for all interactions with the vital api.
30
30
  * @type {string}
31
31
  * @memberof ClientFacingBody
32
32
  */
@@ -29,7 +29,7 @@ export interface ClientFacingSourceSpecific {
29
29
  */
30
30
  data: unknown;
31
31
  /**
32
- * 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.
32
+ * User id returned by vital create user id request. This id should be stored in your database against the user and used for all interactions with the vital api.
33
33
  * @type {string}
34
34
  * @memberof ClientFacingSourceSpecific
35
35
  */
@@ -8,7 +8,16 @@ export interface RawResponse {
8
8
  priority: number;
9
9
  priority_id: number;
10
10
  timestamp: Date;
11
- data: Record<string, string>
11
+ data: Record<string, string>;
12
+ provider_id: string;
13
+ }
14
+
15
+ export interface DeviceRawResponse {
16
+ id: string;
17
+ user_id: string;
18
+ source_id: number;
19
+ source?: SourceClientFacing;
20
+ data: Record<string, string>;
12
21
  provider_id: string;
13
22
  }
14
23
 
@@ -29,3 +38,7 @@ export interface ClientSleepRawResponse {
29
38
  export interface ClientProfileRawResponse {
30
39
  profile: RawResponse[];
31
40
  }
41
+
42
+ export interface ClientDevicesRawResponse {
43
+ devices: DeviceRawResponse[];
44
+ }
@@ -122,7 +122,7 @@ export interface ClientFacingSleep {
122
122
  */
123
123
  source: SourceClientFacing;
124
124
  /**
125
- * 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.
125
+ * User id returned by vital create user id request. This id should be stored in your database against the user and used for all interactions with the vital api.
126
126
  * @type {string}
127
127
  * @memberof ClientFacingSleep
128
128
  */
@@ -35,17 +35,19 @@ export interface Order {
35
35
  created_on: Date;
36
36
  updated_on: Date;
37
37
  status:
38
- | 'ordered'
39
- | 'transit_customer'
40
- | 'out_for_delivery'
41
- | 'with_customer'
42
- | 'transit_lab'
43
- | 'delivered_to_lab'
44
- | 'processing_lab'
45
- | 'completed'
46
- | 'failure_to_deliver_to_customer'
47
- | 'failure_to_deliver_to_lab'
48
- | 'unknown';
38
+ | 'ordered'
39
+ | 'transit_customer'
40
+ | 'out_for_delivery'
41
+ | 'with_customer'
42
+ | 'transit_lab'
43
+ | 'delivered_to_lab'
44
+ | 'processing_lab'
45
+ | 'completed'
46
+ | 'failure_to_deliver_to_customer'
47
+ | 'failure_to_deliver_to_lab'
48
+ | 'cancelled'
49
+ | 'do_not_process'
50
+ | 'unknown';
49
51
  user_key: string;
50
52
  testkit_id: string;
51
53
  testkit: Testkit;
@@ -1,6 +1,6 @@
1
- export interface UserKeyResponse {
1
+ export interface UserIdResponse {
2
2
  client_user_id: string;
3
- user_key: string;
3
+ user_id: string;
4
4
  }
5
5
 
6
6
  export interface SuccessResponse {
@@ -36,6 +36,7 @@ export interface ClientFacingUser {
36
36
  client_user_id: string;
37
37
  created_on: string;
38
38
  connecte_sources: Array<ConnectedSourceClientFacing>;
39
+ user_id: string;
39
40
  }
40
41
 
41
42
  export enum Providers {
@@ -82,7 +82,7 @@ export interface ClientFacingWorkout {
82
82
  */
83
83
  hr_zones: number[];
84
84
  /**
85
- * 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.
85
+ * User id returned by vital create user id request. This id should be stored in your database against the user and used for all interactions with the vital api.
86
86
  * @type {string}
87
87
  * @memberof ClientFacingWorkout
88
88
  */
@@ -5,6 +5,6 @@ export declare class ActivityApi {
5
5
  baseURL: string;
6
6
  client: AxiosInstance;
7
7
  constructor(baseURL: string, axios: AxiosInstance);
8
- get(userKey: string, startDate: Date, endDate: Date, provider?: string): Promise<ClientActivityResponse>;
9
- get_raw(userKey: string, startDate: Date, endDate: Date, provider?: string): Promise<ClientActivityRawResponse>;
8
+ get(userId: string, startDate: Date, endDate?: Date, provider?: string): Promise<ClientActivityResponse>;
9
+ get_raw(userId: string, startDate: Date, endDate?: Date, provider?: string): Promise<ClientActivityRawResponse>;
10
10
  }
@@ -42,12 +42,12 @@ var ActivityApi = /** @class */ (function () {
42
42
  this.baseURL = baseURL;
43
43
  this.client = axios;
44
44
  }
45
- ActivityApi.prototype.get = function (userKey, startDate, endDate, provider) {
45
+ ActivityApi.prototype.get = function (userId, 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("/summary/activity/" + userKey), {
50
+ case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/summary/activity/" + userId), {
51
51
  params: { start_date: startDate, end_date: endDate, provider: provider },
52
52
  })];
53
53
  case 1:
@@ -57,12 +57,12 @@ var ActivityApi = /** @class */ (function () {
57
57
  });
58
58
  });
59
59
  };
60
- ActivityApi.prototype.get_raw = function (userKey, startDate, endDate, provider) {
60
+ ActivityApi.prototype.get_raw = function (userId, startDate, endDate, provider) {
61
61
  return __awaiter(this, void 0, void 0, 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("/summary/activity/" + userKey + "/raw"), {
65
+ case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/summary/activity/" + userId + "/raw"), {
66
66
  params: { start_date: startDate, end_date: endDate, provider: provider },
67
67
  })];
68
68
  case 1:
@@ -5,6 +5,6 @@ export declare class BodyApi {
5
5
  baseURL: string;
6
6
  client: AxiosInstance;
7
7
  constructor(baseURL: string, axios: AxiosInstance);
8
- get(userKey: string, startDate: Date, endDate: Date, provider?: string): Promise<ClientBodyResponse>;
9
- get_raw(userKey: string, startDate: Date, endDate: Date, provider?: string): Promise<ClientBodyRawResponse>;
8
+ get(userId: string, startDate: Date, endDate?: Date, provider?: string): Promise<ClientBodyResponse>;
9
+ get_raw(userId: string, startDate: Date, endDate?: Date, provider?: string): Promise<ClientBodyRawResponse>;
10
10
  }
@@ -42,12 +42,12 @@ var BodyApi = /** @class */ (function () {
42
42
  this.baseURL = baseURL;
43
43
  this.client = axios;
44
44
  }
45
- BodyApi.prototype.get = function (userKey, startDate, endDate, provider) {
45
+ BodyApi.prototype.get = function (userId, 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("/summary/body/" + userKey), {
50
+ case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/summary/body/" + userId), {
51
51
  params: { start_date: startDate, end_date: endDate, provider: provider },
52
52
  })];
53
53
  case 1:
@@ -57,12 +57,12 @@ var BodyApi = /** @class */ (function () {
57
57
  });
58
58
  });
59
59
  };
60
- BodyApi.prototype.get_raw = function (userKey, startDate, endDate, provider) {
60
+ BodyApi.prototype.get_raw = function (userId, startDate, endDate, provider) {
61
61
  return __awaiter(this, void 0, void 0, 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("/summary/body/" + userKey + "/raw"), {
65
+ case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/summary/body/" + userId + "/raw"), {
66
66
  params: { start_date: startDate, end_date: endDate, provider: provider },
67
67
  })];
68
68
  case 1:
@@ -0,0 +1,8 @@
1
+ import { AxiosInstance } from 'axios';
2
+ import { ClientDevicesRawResponse } from './models/raw_response';
3
+ export declare class DevicesAPI {
4
+ baseURL: string;
5
+ client: AxiosInstance;
6
+ constructor(baseURL: string, axios: AxiosInstance);
7
+ get_raw(userId: string, provider?: string): Promise<ClientDevicesRawResponse>;
8
+ }
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.DevicesAPI = void 0;
40
+ var DevicesAPI = /** @class */ (function () {
41
+ function DevicesAPI(baseURL, axios) {
42
+ this.baseURL = baseURL;
43
+ this.client = axios;
44
+ }
45
+ DevicesAPI.prototype.get_raw = function (userId, provider) {
46
+ return __awaiter(this, void 0, void 0, function () {
47
+ var resp;
48
+ return __generator(this, function (_a) {
49
+ switch (_a.label) {
50
+ case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/summary/devices/" + userId + "/raw"), {
51
+ params: { provider: provider },
52
+ })];
53
+ case 1:
54
+ resp = _a.sent();
55
+ return [2 /*return*/, resp.data];
56
+ }
57
+ });
58
+ });
59
+ };
60
+ return DevicesAPI;
61
+ }());
62
+ exports.DevicesAPI = DevicesAPI;
@@ -5,7 +5,7 @@ export declare class LinkApi {
5
5
  baseURL: string;
6
6
  client: AxiosInstance;
7
7
  constructor(baseURL: string, axios: AxiosInstance);
8
- create(userKey: string, provider?: string): Promise<LinkTokenExchangeResponse>;
8
+ create(userId: string, provider?: string): Promise<LinkTokenExchangeResponse>;
9
9
  connectProvider(linkToken: string, provider: PasswordProviders, username: string, password: string): Promise<ProviderLinkResponse>;
10
10
  connectEmailProvider(linkToken: string, provider: EmailProviders, email: string): Promise<ProviderLinkResponse>;
11
11
  getOAuthLink(linkToken: string, provider: OAuthProviders): Promise<SourceWithLinkInfo>;
@@ -42,14 +42,14 @@ var LinkApi = /** @class */ (function () {
42
42
  this.baseURL = baseURL;
43
43
  this.client = axios;
44
44
  }
45
- LinkApi.prototype.create = function (userKey, provider) {
45
+ LinkApi.prototype.create = function (userId, provider) {
46
46
  if (provider === void 0) { provider = null; }
47
47
  return __awaiter(this, void 0, void 0, function () {
48
48
  var resp;
49
49
  return __generator(this, function (_a) {
50
50
  switch (_a.label) {
51
51
  case 0: return [4 /*yield*/, this.client.post(this.baseURL.concat('/link/token/'), {
52
- user_key: userKey,
52
+ user_key: userId,
53
53
  provider: provider,
54
54
  })];
55
55
  case 1:
@@ -5,6 +5,6 @@ export declare class ProfileApi {
5
5
  baseURL: string;
6
6
  client: AxiosInstance;
7
7
  constructor(baseURL: string, axios: AxiosInstance);
8
- get(userKey: string, provider?: string): Promise<ClientFacingProfile>;
9
- get_raw(userKey: string, startDate: Date, endDate: Date, provider?: string): Promise<ClientProfileRawResponse>;
8
+ get(userId: string, provider?: string): Promise<ClientFacingProfile>;
9
+ get_raw(userId: string, startDate: Date, endDate: Date, provider?: string): Promise<ClientProfileRawResponse>;
10
10
  }
@@ -42,12 +42,12 @@ var ProfileApi = /** @class */ (function () {
42
42
  this.baseURL = baseURL;
43
43
  this.client = axios;
44
44
  }
45
- ProfileApi.prototype.get = function (userKey, provider) {
45
+ ProfileApi.prototype.get = function (userId, 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("/summary/profile/" + userKey), {
50
+ case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/summary/profile/" + userId), {
51
51
  params: { provider: provider },
52
52
  })];
53
53
  case 1:
@@ -57,12 +57,12 @@ var ProfileApi = /** @class */ (function () {
57
57
  });
58
58
  });
59
59
  };
60
- ProfileApi.prototype.get_raw = function (userKey, startDate, endDate, provider) {
60
+ ProfileApi.prototype.get_raw = function (userId, startDate, endDate, provider) {
61
61
  return __awaiter(this, void 0, void 0, 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("/summary/profile/" + userKey + "/raw"), {
65
+ case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/summary/profile/" + userId + "/raw"), {
66
66
  params: { start_date: startDate, end_date: endDate, provider: provider },
67
67
  })];
68
68
  case 1:
@@ -47,7 +47,7 @@ var ProviderApi = /** @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("/providers/"))];
50
+ case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat('/providers/'))];
51
51
  case 1:
52
52
  resp = _a.sent();
53
53
  return [2 /*return*/, resp.data];
@@ -5,7 +5,7 @@ export declare class SleepApi {
5
5
  baseURL: string;
6
6
  client: AxiosInstance;
7
7
  constructor(baseURL: string, axios: AxiosInstance);
8
- get(userKey: string, startDate: Date, endDate: Date, provider?: string): Promise<ClientSleepResponse>;
8
+ get(userId: string, startDate: Date, endDate?: Date, provider?: string, with_stream?: boolean): Promise<ClientSleepResponse>;
9
9
  getStream(sleepId: string): Promise<ClientSleepStreamResponse>;
10
- get_raw(userKey: string, startDate: Date, endDate: Date, provider?: string): Promise<ClientSleepRawResponse>;
10
+ get_raw(userId: string, startDate: Date, endDate?: Date, provider?: string): Promise<ClientSleepRawResponse>;
11
11
  }
@@ -42,13 +42,14 @@ var SleepApi = /** @class */ (function () {
42
42
  this.baseURL = baseURL;
43
43
  this.client = axios;
44
44
  }
45
- SleepApi.prototype.get = function (userKey, startDate, endDate, provider) {
45
+ SleepApi.prototype.get = function (userId, startDate, endDate, provider, with_stream) {
46
+ if (with_stream === void 0) { with_stream = false; }
46
47
  return __awaiter(this, void 0, void 0, function () {
47
48
  var resp;
48
49
  return __generator(this, function (_a) {
49
50
  switch (_a.label) {
50
- case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/summary/sleep/" + userKey), {
51
- params: { start_date: startDate, end_date: endDate, provider: provider },
51
+ case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/summary/sleep/" + userId), {
52
+ params: { start_date: startDate, end_date: endDate, provider: provider, with_stream: with_stream },
52
53
  })];
53
54
  case 1:
54
55
  resp = _a.sent();
@@ -70,12 +71,12 @@ var SleepApi = /** @class */ (function () {
70
71
  });
71
72
  });
72
73
  };
73
- SleepApi.prototype.get_raw = function (userKey, startDate, endDate, provider) {
74
+ SleepApi.prototype.get_raw = function (userId, startDate, endDate, provider) {
74
75
  return __awaiter(this, void 0, void 0, function () {
75
76
  var resp;
76
77
  return __generator(this, function (_a) {
77
78
  switch (_a.label) {
78
- case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/summary/sleep/" + userKey + "/raw"), {
79
+ case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/summary/sleep/" + userId + "/raw"), {
79
80
  params: { start_date: startDate, end_date: endDate, provider: provider },
80
81
  })];
81
82
  case 1:
@@ -5,9 +5,10 @@ export declare class TestkitsApi {
5
5
  client: AxiosInstance;
6
6
  constructor(baseURL: string, axios: AxiosInstance);
7
7
  get(): Promise<TestkitResponse>;
8
- get_orders(startDate: Date, endDate: Date): Promise<OrderResponse>;
9
- order(userKey: string, testkitId: string, patientAddress: PatientAdress, patientDetails: PatientDetails): Promise<OrderRequestResponse>;
8
+ get_orders(startDate: Date, endDate: Date, status?: string[]): Promise<OrderResponse>;
9
+ order(userId: string, testkitId: string, patientAddress: PatientAdress, patientDetails: PatientDetails): Promise<OrderRequestResponse>;
10
10
  get_order(orderId: string): Promise<Order>;
11
+ cancel_order(orderId: string): Promise<OrderRequestResponse>;
11
12
  get_results(orderId: string): Promise<string>;
12
13
  getMetadata(orderId: string): Promise<LabResultsMetadata>;
13
14
  getRawResults(orderId: string): Promise<LabResultsRaw>;
@@ -55,13 +55,13 @@ var TestkitsApi = /** @class */ (function () {
55
55
  });
56
56
  });
57
57
  };
58
- TestkitsApi.prototype.get_orders = function (startDate, endDate) {
58
+ TestkitsApi.prototype.get_orders = function (startDate, endDate, status) {
59
59
  return __awaiter(this, void 0, void 0, function () {
60
60
  var resp;
61
61
  return __generator(this, function (_a) {
62
62
  switch (_a.label) {
63
63
  case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat('/testkit/orders/'), {
64
- params: { start_date: startDate, end_date: endDate },
64
+ params: { start_date: startDate, end_date: endDate, status: status ? status : null },
65
65
  })];
66
66
  case 1:
67
67
  resp = _a.sent();
@@ -70,13 +70,13 @@ var TestkitsApi = /** @class */ (function () {
70
70
  });
71
71
  });
72
72
  };
73
- TestkitsApi.prototype.order = function (userKey, testkitId, patientAddress, patientDetails) {
73
+ TestkitsApi.prototype.order = function (userId, testkitId, patientAddress, patientDetails) {
74
74
  return __awaiter(this, void 0, void 0, function () {
75
75
  var resp;
76
76
  return __generator(this, function (_a) {
77
77
  switch (_a.label) {
78
78
  case 0: return [4 /*yield*/, this.client.post(this.baseURL.concat('/testkit/orders'), {
79
- user_key: userKey,
79
+ user_key: userId,
80
80
  testkit_id: testkitId,
81
81
  patient_address: patientAddress,
82
82
  patient_details: patientDetails,
@@ -101,6 +101,19 @@ var TestkitsApi = /** @class */ (function () {
101
101
  });
102
102
  });
103
103
  };
104
+ TestkitsApi.prototype.cancel_order = 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.post(this.baseURL.concat("/testkit/orders/" + orderId + "/cancel"))];
110
+ case 1:
111
+ resp = _a.sent();
112
+ return [2 /*return*/, resp.data];
113
+ }
114
+ });
115
+ });
116
+ };
104
117
  TestkitsApi.prototype.get_results = function (orderId) {
105
118
  return __awaiter(this, void 0, void 0, function () {
106
119
  var resp;
@@ -1,14 +1,15 @@
1
1
  import { AxiosInstance } from 'axios';
2
- import { UserKeyResponse, SuccessResponse, ClientFacingUser, Providers, ProvidersResponse } from './models/user_models';
2
+ import { UserIdResponse, SuccessResponse, ClientFacingUser, Providers, ProvidersResponse } from './models/user_models';
3
3
  export declare class UserApi {
4
4
  baseURL: string;
5
5
  client: AxiosInstance;
6
6
  constructor(baseURL: string, axios: AxiosInstance);
7
- create(clientUserId: string): Promise<UserKeyResponse>;
8
- delete(userKey: string): Promise<SuccessResponse>;
7
+ create(clientUserId: string): Promise<UserIdResponse>;
8
+ delete(userId: string): Promise<SuccessResponse>;
9
9
  getAll(): Promise<Array<ClientFacingUser>>;
10
- get(userKey: string): Promise<ClientFacingUser>;
10
+ get(userId: string): Promise<ClientFacingUser>;
11
11
  resolve(clientUserId: string): Promise<ClientFacingUser>;
12
- providers(userKey: string): Promise<ProvidersResponse>;
13
- deregisterProvider(userKey: string, provider: Providers): Promise<SuccessResponse>;
12
+ providers(userId: string): Promise<ProvidersResponse>;
13
+ deregisterProvider(userId: string, provider: Providers): Promise<SuccessResponse>;
14
+ refresh(userId: string): Promise<SuccessResponse>;
14
15
  }