@integraciones_doc24/sdk 1.16.16 → 1.16.18

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.
@@ -1,3 +1,4 @@
1
1
  import { Doc24 } from '../types';
2
+ import FormData from 'form-data';
2
3
  export declare const getRequestFactory: (url: string, credentials: Doc24.SdkCredentials, userId?: number | undefined) => Promise<RequestMaker>;
3
- export declare type RequestMaker = (method: 'POST' | 'GET' | 'PUT' | 'DELETE', path: string, body?: object) => Promise<any>;
4
+ export declare type RequestMaker = (method: 'POST' | 'GET' | 'PUT' | 'DELETE', path: string, body?: object | FormData) => Promise<any>;
@@ -7,15 +7,21 @@ exports.getRequestFactory = void 0;
7
7
  const axios_1 = __importDefault(require("axios"));
8
8
  const token_1 = require("./token");
9
9
  const debug_1 = __importDefault(require("debug"));
10
+ const form_data_1 = __importDefault(require("form-data"));
10
11
  const debugRequest = debug_1.default('doc24Sdk:request');
11
12
  const getRequestFactory = async (url, credentials, userId) => {
12
13
  const makeRequest = async (method, path, body) => {
13
- const token = await token_1.getToken(credentials, body ? JSON.stringify(body) : undefined, userId);
14
+ const isMultipart = body instanceof form_data_1.default;
15
+ const token = await token_1.getToken(credentials, body && !isMultipart ? JSON.stringify(body) : undefined, userId);
14
16
  const fullUrl = url + path;
17
+ let headers = { Authentication: token };
18
+ if (isMultipart) {
19
+ headers = { ...headers, ...body.getHeaders() };
20
+ }
15
21
  const result = await axios_1.default({
16
22
  method,
17
23
  url: fullUrl,
18
- headers: { Authentication: token },
24
+ headers,
19
25
  data: body,
20
26
  });
21
27
  debugRequest({ url: fullUrl, response: result.data, body });
package/lib/schemas.d.ts CHANGED
@@ -928,16 +928,16 @@ export declare const doc24Schemas: {
928
928
  inPersonRequired: import("zod").ZodNullable<import("zod").ZodOptional<import("zod").ZodString>>;
929
929
  referral: import("zod").ZodObject<{
930
930
  status: import("zod").ZodNullable<import("zod").ZodOptional<import("zod").ZodString>>;
931
- specialtyId: import("zod").ZodNullable<import("zod").ZodOptional<import("zod").ZodNumber>>;
931
+ specialtyId: import("zod").ZodAny;
932
932
  inPersonRequired: import("zod").ZodNullable<import("zod").ZodOptional<import("zod").ZodString>>;
933
933
  comments: import("zod").ZodNullable<import("zod").ZodOptional<import("zod").ZodString>>;
934
934
  }, "strip", import("zod").ZodTypeAny, {
935
- specialtyId?: number | null | undefined;
935
+ specialtyId?: any;
936
936
  status?: string | null | undefined;
937
937
  inPersonRequired?: string | null | undefined;
938
938
  comments?: string | null | undefined;
939
939
  }, {
940
- specialtyId?: number | null | undefined;
940
+ specialtyId?: any;
941
941
  status?: string | null | undefined;
942
942
  inPersonRequired?: string | null | undefined;
943
943
  comments?: string | null | undefined;
@@ -964,7 +964,7 @@ export declare const doc24Schemas: {
964
964
  codigo?: number | null | undefined;
965
965
  };
966
966
  referral: {
967
- specialtyId?: number | null | undefined;
967
+ specialtyId?: any;
968
968
  status?: string | null | undefined;
969
969
  inPersonRequired?: string | null | undefined;
970
970
  comments?: string | null | undefined;
@@ -991,7 +991,7 @@ export declare const doc24Schemas: {
991
991
  codigo?: number | null | undefined;
992
992
  };
993
993
  referral: {
994
- specialtyId?: number | null | undefined;
994
+ specialtyId?: any;
995
995
  status?: string | null | undefined;
996
996
  inPersonRequired?: string | null | undefined;
997
997
  comments?: string | null | undefined;
@@ -1003,21 +1003,21 @@ export declare const doc24Schemas: {
1003
1003
  otherExams: import("zod").ZodAny;
1004
1004
  images: import("zod").ZodAny;
1005
1005
  medication: import("zod").ZodArray<import("zod").ZodAny, "many">;
1006
- certificate: import("zod").ZodArray<import("zod").ZodAny, "many">;
1006
+ certificate: import("zod").ZodNullable<import("zod").ZodOptional<import("zod").ZodUnion<[import("zod").ZodArray<import("zod").ZodAny, "many">, import("zod").ZodString]>>>;
1007
1007
  }, "strip", import("zod").ZodTypeAny, {
1008
1008
  atention?: any;
1009
1009
  labs?: any;
1010
1010
  otherExams?: any;
1011
1011
  images?: any;
1012
+ certificate?: string | any[] | null | undefined;
1012
1013
  medication: any[];
1013
- certificate: any[];
1014
1014
  }, {
1015
1015
  atention?: any;
1016
1016
  labs?: any;
1017
1017
  otherExams?: any;
1018
1018
  images?: any;
1019
+ certificate?: string | any[] | null | undefined;
1019
1020
  medication: any[];
1020
- certificate: any[];
1021
1021
  }>;
1022
1022
  files: import("zod").ZodArray<import("zod").ZodObject<{
1023
1023
  name: import("zod").ZodString;
@@ -1064,7 +1064,7 @@ export declare const doc24Schemas: {
1064
1064
  codigo?: number | null | undefined;
1065
1065
  };
1066
1066
  referral: {
1067
- specialtyId?: number | null | undefined;
1067
+ specialtyId?: any;
1068
1068
  status?: string | null | undefined;
1069
1069
  inPersonRequired?: string | null | undefined;
1070
1070
  comments?: string | null | undefined;
@@ -1075,8 +1075,8 @@ export declare const doc24Schemas: {
1075
1075
  labs?: any;
1076
1076
  otherExams?: any;
1077
1077
  images?: any;
1078
+ certificate?: string | any[] | null | undefined;
1078
1079
  medication: any[];
1079
- certificate: any[];
1080
1080
  };
1081
1081
  files: {
1082
1082
  name: string;
@@ -1117,7 +1117,7 @@ export declare const doc24Schemas: {
1117
1117
  codigo?: number | null | undefined;
1118
1118
  };
1119
1119
  referral: {
1120
- specialtyId?: number | null | undefined;
1120
+ specialtyId?: any;
1121
1121
  status?: string | null | undefined;
1122
1122
  inPersonRequired?: string | null | undefined;
1123
1123
  comments?: string | null | undefined;
@@ -1128,8 +1128,8 @@ export declare const doc24Schemas: {
1128
1128
  labs?: any;
1129
1129
  otherExams?: any;
1130
1130
  images?: any;
1131
+ certificate?: string | any[] | null | undefined;
1131
1132
  medication: any[];
1132
- certificate: any[];
1133
1133
  };
1134
1134
  files: {
1135
1135
  name: string;
@@ -2432,4 +2432,17 @@ export declare const doc24Schemas: {
2432
2432
  emailCode?: undefined;
2433
2433
  phoneCode: string;
2434
2434
  }>;
2435
+ uploadFileConsultationParams: import("zod").ZodObject<{
2436
+ vcToken: import("zod").ZodString;
2437
+ attachedFile: import("zod").ZodString;
2438
+ fileName: import("zod").ZodOptional<import("zod").ZodString>;
2439
+ }, "strip", import("zod").ZodTypeAny, {
2440
+ fileName?: string | undefined;
2441
+ vcToken: string;
2442
+ attachedFile: string;
2443
+ }, {
2444
+ fileName?: string | undefined;
2445
+ vcToken: string;
2446
+ attachedFile: string;
2447
+ }>;
2435
2448
  };
package/lib/schemas.js CHANGED
@@ -434,7 +434,7 @@ exports.doc24Schemas = {
434
434
  inPersonRequired: zod_1.string().nullish(),
435
435
  referral: zod_1.object({
436
436
  status: zod_1.string().nullish(),
437
- specialtyId: zod_1.number().nullish(),
437
+ specialtyId: zod_1.any(),
438
438
  inPersonRequired: zod_1.string().nullish(),
439
439
  comments: zod_1.string().nullish(),
440
440
  }),
@@ -445,7 +445,7 @@ exports.doc24Schemas = {
445
445
  otherExams: zod_1.any(),
446
446
  images: zod_1.any(),
447
447
  medication: zod_1.array(zod_1.any()),
448
- certificate: zod_1.array(zod_1.any()),
448
+ certificate: zod_1.array(zod_1.any()).or(zod_1.string()).nullish(),
449
449
  }),
450
450
  files: zod_1.array(zod_1.object({ name: zod_1.string(), url: zod_1.string().url() })),
451
451
  }),
@@ -520,4 +520,9 @@ exports.doc24Schemas = {
520
520
  binahWellnessGetLinkParams,
521
521
  emailOrPhone,
522
522
  emailOrPhoneCode,
523
+ uploadFileConsultationParams: zod_1.object({
524
+ vcToken: zod_1.string(),
525
+ attachedFile: zod_1.string(),
526
+ fileName: zod_1.string().optional(),
527
+ }),
523
528
  };
package/lib/types.d.ts CHANGED
@@ -50,6 +50,7 @@ export declare namespace Doc24 {
50
50
  type BinahWellnessGetLinkParams = TypeOf<typeof doc24Schemas.binahWellnessGetLinkParams>;
51
51
  type BinahWellnessResponse = TypeOf<typeof doc24Schemas.binahWellnessResponse>;
52
52
  type ProfessionalsBySpecialtyFilter = TypeOf<typeof doc24Schemas.professionalsBySpecialtyFilter>;
53
+ type UploadFileConsultationParams = TypeOf<typeof doc24Schemas.uploadFileConsultationParams>;
53
54
  type BaseSdk = {
54
55
  declareUser: (params: DeclareUserParams) => Promise<DeclareUserResponse>;
55
56
  getUserId: (user: User) => Promise<number>;
@@ -100,6 +101,7 @@ export declare namespace Doc24 {
100
101
  getPatientPHR: (patientId: number) => Promise<string>;
101
102
  userId: number;
102
103
  getBinahWellnessLink: (body: BinahWellnessGetLinkParams) => Promise<BinahWellnessResponse>;
104
+ uploadFileConsultation: (params: UploadFileConsultationParams) => Promise<unknown>;
103
105
  };
104
106
  namespace Webhook {
105
107
  type StatusChangeEventStatus = 'S' | 'C' | 'F' | 'A' | 'D' | 'L';
@@ -147,7 +147,7 @@ export declare const getVideoVisitMethods: (makeRequest: RequestMaker) => {
147
147
  codigo?: number | null | undefined;
148
148
  };
149
149
  referral: {
150
- specialtyId?: number | null | undefined;
150
+ specialtyId?: any;
151
151
  status?: string | null | undefined;
152
152
  inPersonRequired?: string | null | undefined;
153
153
  comments?: string | null | undefined;
@@ -158,12 +158,17 @@ export declare const getVideoVisitMethods: (makeRequest: RequestMaker) => {
158
158
  labs?: any;
159
159
  otherExams?: any;
160
160
  images?: any;
161
+ certificate?: string | any[] | null | undefined;
161
162
  medication: any[];
162
- certificate: any[];
163
163
  };
164
164
  files: {
165
165
  name: string;
166
166
  url: string;
167
167
  }[];
168
168
  }>;
169
+ uploadFileConsultation: (params: {
170
+ fileName?: string | undefined;
171
+ vcToken: string;
172
+ attachedFile: string;
173
+ }) => Promise<unknown>;
169
174
  };
@@ -1,10 +1,15 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.getVideoVisitMethods = void 0;
4
7
  const zod_1 = require("zod");
5
8
  const validation_1 = require("../request/validation");
6
9
  const schemas_1 = require("../schemas");
7
10
  const utils_1 = require("../utils");
11
+ const fs_1 = __importDefault(require("fs"));
12
+ const form_data_1 = __importDefault(require("form-data"));
8
13
  const getVideoVisitMethods = (makeRequest) => {
9
14
  const scheduleVideoVisit = validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.scheduleParameters]), zod_1.string(), async (params) => {
10
15
  const specificParams = params.type === 'appointment'
@@ -183,6 +188,15 @@ const getVideoVisitMethods = (makeRequest) => {
183
188
  })),
184
189
  };
185
190
  });
191
+ const uploadFileConsultation = validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.uploadFileConsultationParams]), zod_1.any(), async (params) => {
192
+ const form = new form_data_1.default();
193
+ form.append('vc_token', params.vcToken);
194
+ form.append('attached_file', fs_1.default.createReadStream(params.filePath));
195
+ if (params.fileName)
196
+ form.append('file_name', params.fileName);
197
+ const response = await makeRequest('POST', '/upload-file-consultation', form);
198
+ return response.data;
199
+ });
186
200
  return {
187
201
  scheduleVideoVisit,
188
202
  cancelVideoVisit,
@@ -192,6 +206,7 @@ const getVideoVisitMethods = (makeRequest) => {
192
206
  getVideoVisitLink,
193
207
  getActiveVideoVisits,
194
208
  getCompleteVideoVisitDetails,
209
+ uploadFileConsultation,
195
210
  };
196
211
  };
197
212
  exports.getVideoVisitMethods = getVideoVisitMethods;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@integraciones_doc24/sdk",
3
- "version": "1.16.16",
3
+ "version": "1.16.18",
4
4
  "publishConfig": {
5
5
  "tag": "latest"
6
6
  },
@@ -17,14 +17,15 @@
17
17
  "dependencies": {
18
18
  "axios": "^0.21.0",
19
19
  "date-fns": "^2.16.1",
20
+ "form-data": "^4.0.5",
20
21
  "jsonwebtoken": "^8.5.1",
21
22
  "zod": "^3.8.1"
22
23
  },
23
24
  "devDependencies": {
24
25
  "@types/debug": "^4.1.7",
25
26
  "@types/jsonwebtoken": "^8.5.0",
26
- "typescript": "^4.1.3",
27
- "debug": "^4.3.4"
27
+ "debug": "^4.3.4",
28
+ "typescript": "^4.1.3"
28
29
  },
29
30
  "peerDependencies": {
30
31
  "debug": "*"