@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
@@ -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
  */
@@ -0,0 +1,19 @@
1
+ export enum Resource {
2
+ WORKOUTS = 'workouts',
3
+ ACTVITY = 'activity',
4
+ SLEEP = 'sleep',
5
+ BODY = 'body',
6
+ WORKOUTS_STREAM = 'workouts/stream',
7
+ SLEEP_STREAM = 'sleep/stream',
8
+ HEARTRATE = 'heartrate',
9
+ GLUCOSE = 'glucose',
10
+ PROFILE = 'profile',
11
+ }
12
+
13
+ export interface Provider {
14
+ name: string;
15
+ slug: string;
16
+ logo: string;
17
+ auth_type: 'password' | 'email' | 'oauth';
18
+ supported_resources: Resource[];
19
+ }
@@ -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;
@@ -68,3 +70,22 @@ export interface OrderRequestResponse {
68
70
  export interface TestkitResponse {
69
71
  testkits: Testkit[];
70
72
  }
73
+
74
+ export interface LabResultsMetadata {
75
+ age: string;
76
+ dob: string;
77
+ clia_number: string;
78
+ patient: string;
79
+ provider: string;
80
+ laboratory: string;
81
+ date_reported: string;
82
+ date_collected: string;
83
+ specimen_number: string;
84
+ date_received?: string;
85
+ clia?: string;
86
+ }
87
+
88
+ export interface LabResultsRaw {
89
+ metadata: LabResultsMetadata;
90
+ data: Record<string, string>;
91
+ }
@@ -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:
@@ -0,0 +1,8 @@
1
+ import { AxiosInstance } from 'axios';
2
+ import { Provider } from './models/provider_models';
3
+ export declare class ProviderApi {
4
+ baseURL: string;
5
+ client: AxiosInstance;
6
+ constructor(baseURL: string, axios: AxiosInstance);
7
+ getSupportedProviders(): Promise<Provider[]>;
8
+ }
@@ -0,0 +1,60 @@
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.ProviderApi = void 0;
40
+ var ProviderApi = /** @class */ (function () {
41
+ function ProviderApi(baseURL, axios) {
42
+ this.baseURL = baseURL;
43
+ this.client = axios;
44
+ }
45
+ ProviderApi.prototype.getSupportedProviders = function () {
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('/providers/'))];
51
+ case 1:
52
+ resp = _a.sent();
53
+ return [2 /*return*/, resp.data];
54
+ }
55
+ });
56
+ });
57
+ };
58
+ return ProviderApi;
59
+ }());
60
+ exports.ProviderApi = ProviderApi;
@@ -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): 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,12 +42,12 @@ 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) {
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/sleep/" + userKey), {
50
+ case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/summary/sleep/" + userId), {
51
51
  params: { start_date: startDate, end_date: endDate, provider: provider },
52
52
  })];
53
53
  case 1:
@@ -70,12 +70,12 @@ var SleepApi = /** @class */ (function () {
70
70
  });
71
71
  });
72
72
  };
73
- SleepApi.prototype.get_raw = function (userKey, startDate, endDate, provider) {
73
+ SleepApi.prototype.get_raw = function (userId, startDate, endDate, provider) {
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
- case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/summary/sleep/" + userKey + "/raw"), {
78
+ case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/summary/sleep/" + userId + "/raw"), {
79
79
  params: { start_date: startDate, end_date: endDate, provider: provider },
80
80
  })];
81
81
  case 1:
@@ -1,12 +1,15 @@
1
1
  import { AxiosInstance } from 'axios';
2
- import { Order, OrderRequestResponse, OrderResponse, PatientAdress, PatientDetails, TestkitResponse } from './models/testkit_models';
2
+ import { LabResultsMetadata, LabResultsRaw, Order, OrderRequestResponse, OrderResponse, PatientAdress, PatientDetails, TestkitResponse } from './models/testkit_models';
3
3
  export declare class TestkitsApi {
4
4
  baseURL: string;
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>;
13
+ getMetadata(orderId: string): Promise<LabResultsMetadata>;
14
+ getRawResults(orderId: string): Promise<LabResultsRaw>;
12
15
  }
@@ -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;
@@ -116,6 +129,32 @@ var TestkitsApi = /** @class */ (function () {
116
129
  });
117
130
  });
118
131
  };
132
+ TestkitsApi.prototype.getMetadata = function (orderId) {
133
+ return __awaiter(this, void 0, void 0, function () {
134
+ var resp;
135
+ return __generator(this, function (_a) {
136
+ switch (_a.label) {
137
+ case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/testkit/orders/" + orderId + "/results/metadata"))];
138
+ case 1:
139
+ resp = _a.sent();
140
+ return [2 /*return*/, resp.data];
141
+ }
142
+ });
143
+ });
144
+ };
145
+ TestkitsApi.prototype.getRawResults = function (orderId) {
146
+ return __awaiter(this, void 0, void 0, function () {
147
+ var resp;
148
+ return __generator(this, function (_a) {
149
+ switch (_a.label) {
150
+ case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/testkit/orders/" + orderId + "/results/raw"))];
151
+ case 1:
152
+ resp = _a.sent();
153
+ return [2 /*return*/, resp.data];
154
+ }
155
+ });
156
+ });
157
+ };
119
158
  return TestkitsApi;
120
159
  }());
121
160
  exports.TestkitsApi = TestkitsApi;
@@ -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
  }