@integraciones_doc24/sdk 1.16.17 → 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.
- package/lib/request/index.d.ts +2 -1
- package/lib/request/index.js +8 -2
- package/lib/schemas.d.ts +13 -0
- package/lib/schemas.js +5 -0
- package/lib/types.d.ts +2 -0
- package/lib/userSdk/videoVisit.d.ts +5 -0
- package/lib/userSdk/videoVisit.js +15 -0
- package/package.json +4 -3
package/lib/request/index.d.ts
CHANGED
|
@@ -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>;
|
package/lib/request/index.js
CHANGED
|
@@ -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
|
|
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
|
|
24
|
+
headers,
|
|
19
25
|
data: body,
|
|
20
26
|
});
|
|
21
27
|
debugRequest({ url: fullUrl, response: result.data, body });
|
package/lib/schemas.d.ts
CHANGED
|
@@ -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
|
@@ -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';
|
|
@@ -166,4 +166,9 @@ export declare const getVideoVisitMethods: (makeRequest: RequestMaker) => {
|
|
|
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.
|
|
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
|
-
"
|
|
27
|
-
"
|
|
27
|
+
"debug": "^4.3.4",
|
|
28
|
+
"typescript": "^4.1.3"
|
|
28
29
|
},
|
|
29
30
|
"peerDependencies": {
|
|
30
31
|
"debug": "*"
|