@integraciones_doc24/sdk 0.39.4 → 0.39.5
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/README.md +93 -83
- package/package.json +1 -1
- package/lib/baseSdk/diagnostica.d.ts +0 -54
- package/lib/baseSdk/diagnostica.js +0 -79
- package/lib/baseSdk/external.d.ts +0 -177
- package/lib/baseSdk/external.js +0 -96
- package/lib/baseSdk/index.d.ts +0 -2
- package/lib/baseSdk/index.js +0 -70
- package/lib/baseSdk/user.d.ts +0 -41
- package/lib/baseSdk/user.js +0 -88
- package/lib/index.d.ts +0 -159
- package/lib/index.js +0 -22
- package/lib/request/index.d.ts +0 -3
- package/lib/request/index.js +0 -26
- package/lib/request/token.d.ts +0 -2
- package/lib/request/token.js +0 -34
- package/lib/request/validation.d.ts +0 -10
- package/lib/request/validation.js +0 -28
- package/lib/schemas.d.ts +0 -1125
- package/lib/schemas.js +0 -307
- package/lib/types.d.ts +0 -118
- package/lib/types.js +0 -2
- package/lib/userSdk/chat.d.ts +0 -57
- package/lib/userSdk/chat.js +0 -98
- package/lib/userSdk/external.d.ts +0 -34
- package/lib/userSdk/external.js +0 -71
- package/lib/userSdk/index.d.ts +0 -2
- package/lib/userSdk/index.js +0 -27
- package/lib/userSdk/patients.d.ts +0 -24
- package/lib/userSdk/patients.js +0 -46
- package/lib/userSdk/schedule.d.ts +0 -44
- package/lib/userSdk/schedule.js +0 -76
- package/lib/userSdk/specialties.d.ts +0 -7
- package/lib/userSdk/specialties.js +0 -19
- package/lib/userSdk/videoVisit.d.ts +0 -111
- package/lib/userSdk/videoVisit.js +0 -147
- package/lib/utils.d.ts +0 -4
- package/lib/utils.js +0 -27
- package/lib/webhook/index.d.ts +0 -2
- package/lib/webhook/index.js +0 -55
- package/lib/webhook/responses.d.ts +0 -35
- package/lib/webhook/responses.js +0 -42
- package/lib/webhook/token.d.ts +0 -2
- package/lib/webhook/token.js +0 -23
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @integraciones_doc24/sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Node.JS library for accessing doc24 api
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -9,48 +9,55 @@
|
|
|
9
9
|
## Usage
|
|
10
10
|
|
|
11
11
|
```ts
|
|
12
|
-
import {doc24Sdk} from '@integraciones_doc24/sdk'
|
|
12
|
+
import {doc24Sdk} from '@integraciones_doc24/sdk';
|
|
13
13
|
|
|
14
|
-
const getBaseSdk = () =>
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
14
|
+
const getBaseSdk = () =>
|
|
15
|
+
doc24Sdk({
|
|
16
|
+
url: 'https://tapi.doc24.com.ar/ws/sdk',
|
|
17
|
+
credentials: {
|
|
18
|
+
iss: 'myissuer',
|
|
19
|
+
key: 'mysecret',
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const getSpecialities = async (user) => {
|
|
24
|
+
const baseSdk = await getBaseSdk();
|
|
24
25
|
|
|
25
|
-
|
|
26
|
+
const userSdk = await baseSdk.getUserInstance(user);
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
}
|
|
28
|
+
return await userSdk.getSpecialties('instant', 'ES');
|
|
29
|
+
};
|
|
29
30
|
|
|
30
31
|
const getRequestHandler = async () => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
32
|
+
const baseSdk = await getBaseSdk();
|
|
33
|
+
return baseSdk.getRequestHandler({
|
|
34
|
+
credentials: {
|
|
35
|
+
iss: 'doc24issuer',
|
|
36
|
+
key: 'doc24secret',
|
|
37
|
+
},
|
|
38
|
+
baseAddress: 'http://myaddress.com/route/to/webhook',
|
|
39
|
+
eventHandlers: {
|
|
40
|
+
onAppointmentStatusChange: ({id, status, changeDate}) => {
|
|
41
|
+
console.log({id, status, changeDate});
|
|
42
|
+
},
|
|
43
|
+
onConsultationStatusChange: ({
|
|
44
|
+
id,
|
|
45
|
+
invitationId,
|
|
46
|
+
status,
|
|
47
|
+
changeDate,
|
|
48
|
+
vcToken,
|
|
49
|
+
}) => {
|
|
50
|
+
console.log({id, invitationId, status, changeDate, vcToken});
|
|
51
|
+
},
|
|
52
|
+
onInvitationStatusChange: ({id, status, changeDate}) => {
|
|
53
|
+
console.log({id, status, changeDate});
|
|
54
|
+
},
|
|
55
|
+
onChatUpdate: ({id, status, patientId, professionalId, date}) => {
|
|
56
|
+
console.log({id, status, patientId, professionalId, date});
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
};
|
|
54
61
|
```
|
|
55
62
|
|
|
56
63
|
The library exports the function `doc24Sdk`. It takes one parameters of type `SdkParams`, and returns a `BaseSdk`.
|
|
@@ -58,69 +65,72 @@ It also returns an extra `getRequestHandler` function that takes a `RequestHandl
|
|
|
58
65
|
|
|
59
66
|
```ts
|
|
60
67
|
type SdkCredentials = {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
68
|
+
iss: string;
|
|
69
|
+
key: string;
|
|
70
|
+
};
|
|
64
71
|
type SdkParams = {
|
|
65
|
-
|
|
66
|
-
|
|
72
|
+
url: string;
|
|
73
|
+
credentials: SdkCredentials;
|
|
67
74
|
};
|
|
68
75
|
type BaseSdk = {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
76
|
+
getUserInstance: (user: User) => Promise<UserSdk>;
|
|
77
|
+
getProfessional: (professionalId: number) => Promise<Professional>;
|
|
78
|
+
getAvailableScheduleClinics: () => Promise<AvailableScheduleClinics>;
|
|
79
|
+
getConsultation: (consultationId: number) => Promise<Consultation | null>;
|
|
80
|
+
};
|
|
73
81
|
|
|
74
82
|
type RequestHandlerParams = {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
83
|
+
// Credentials that doc24 should use when singing the jwt
|
|
84
|
+
credentials: SdkCredentials;
|
|
85
|
+
eventHandlers: Webhook.Events;
|
|
86
|
+
// Address in which doc24 should send the requests
|
|
87
|
+
baseAddress: string;
|
|
88
|
+
};
|
|
81
89
|
```
|
|
82
90
|
|
|
83
91
|
`getRequestHandler` should be called only once, and takes care of managing the webhook that receives events from doc24.
|
|
84
92
|
|
|
85
93
|
### Express example
|
|
94
|
+
|
|
86
95
|
```ts
|
|
87
|
-
const handler = await getRequestHandler()
|
|
96
|
+
const handler = await getRequestHandler();
|
|
88
97
|
app.all('/doc24', async (req, res) => {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
98
|
+
const response = await handler({
|
|
99
|
+
headers: req.headers,
|
|
100
|
+
body: req.body,
|
|
101
|
+
query: req.query,
|
|
102
|
+
});
|
|
94
103
|
|
|
95
|
-
|
|
104
|
+
res.status(response.status.code).json(response.data);
|
|
96
105
|
});
|
|
97
106
|
```
|
|
98
107
|
|
|
99
108
|
### UserSdk
|
|
109
|
+
|
|
100
110
|
Most of the methods need a user specified, so `getUserInstance` returns an instance of `UserSdk` with them.
|
|
101
111
|
|
|
102
112
|
```ts
|
|
103
113
|
type UserSdk = {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
```
|
|
114
|
+
declarePatient: (patient: Patient) => Promise<number>;
|
|
115
|
+
getSpecialties: (
|
|
116
|
+
mode: SpecialtyMode,
|
|
117
|
+
language: string,
|
|
118
|
+
) => Promise<Specialty[]>;
|
|
119
|
+
getScheduleDates: (
|
|
120
|
+
patientId: number,
|
|
121
|
+
filter?: ScheduleAvailabilityFilter,
|
|
122
|
+
) => Promise<Date[]>;
|
|
123
|
+
getSchedule: (
|
|
124
|
+
patientId: number,
|
|
125
|
+
specialtyId: number,
|
|
126
|
+
filter?: ScheduleFilter,
|
|
127
|
+
) => Promise<AvailableAppointment[]>;
|
|
128
|
+
getAppointment: (appointmentId: number) => Promise<Appointment>;
|
|
129
|
+
scheduleVideoVisit: (params: ScheduleParameters) => Promise<string>;
|
|
130
|
+
cancelVideoVisit: (vcToken: string) => Promise<void>;
|
|
131
|
+
getVideoVisit: (vcToken: string, patientId: number) => Promise<VideoVisit>;
|
|
132
|
+
getVideoVisitDetails: (vcId: number) => Promise<VideoVisitDetails>;
|
|
133
|
+
getPatientVideoVisitHistory: (patientId: number) => Promise<VideoVisit[]>;
|
|
134
|
+
userId: number;
|
|
135
|
+
};
|
|
136
|
+
```
|
package/package.json
CHANGED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { RequestMaker } from '../request';
|
|
2
|
-
export declare const getDiagnosticaMethods: (makeRequest: RequestMaker) => {
|
|
3
|
-
getDiagnosticaHistory: (patient: {
|
|
4
|
-
identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg";
|
|
5
|
-
identificationValue: string;
|
|
6
|
-
gender: "m" | "f";
|
|
7
|
-
}, from: Date, to: Date) => Promise<{
|
|
8
|
-
date: Date;
|
|
9
|
-
location: string;
|
|
10
|
-
exams: string[];
|
|
11
|
-
deepLink: string;
|
|
12
|
-
}[]>;
|
|
13
|
-
getDiagnosticaDeepLink: (kiosk: string, user: {
|
|
14
|
-
language: string;
|
|
15
|
-
firstName: string;
|
|
16
|
-
lastName: string;
|
|
17
|
-
birthday: Date;
|
|
18
|
-
identificationType: "dni";
|
|
19
|
-
identificationValue: string;
|
|
20
|
-
gender: "m" | "f";
|
|
21
|
-
phone: string;
|
|
22
|
-
email: string;
|
|
23
|
-
}, patient: {
|
|
24
|
-
firstName: string;
|
|
25
|
-
lastName: string;
|
|
26
|
-
birthday: Date;
|
|
27
|
-
identificationType: "dni";
|
|
28
|
-
identificationValue: string;
|
|
29
|
-
gender: "m" | "f";
|
|
30
|
-
}) => Promise<{
|
|
31
|
-
forwardingRequired: true;
|
|
32
|
-
deepLink: string;
|
|
33
|
-
} | {
|
|
34
|
-
forwardingRequired: false;
|
|
35
|
-
}>;
|
|
36
|
-
getDiagnosticaAccess: (kiosk: string, user: {
|
|
37
|
-
language: string;
|
|
38
|
-
firstName: string;
|
|
39
|
-
lastName: string;
|
|
40
|
-
birthday: Date;
|
|
41
|
-
identificationType: "dni";
|
|
42
|
-
identificationValue: string;
|
|
43
|
-
gender: "m" | "f";
|
|
44
|
-
phone: string;
|
|
45
|
-
email: string;
|
|
46
|
-
}, patient: {
|
|
47
|
-
firstName: string;
|
|
48
|
-
lastName: string;
|
|
49
|
-
birthday: Date;
|
|
50
|
-
identificationType: "dni";
|
|
51
|
-
identificationValue: string;
|
|
52
|
-
gender: "m" | "f";
|
|
53
|
-
}) => Promise<void>;
|
|
54
|
-
};
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getDiagnosticaMethods = void 0;
|
|
4
|
-
const date_fns_1 = require("date-fns");
|
|
5
|
-
const zod_1 = require("zod");
|
|
6
|
-
const validation_1 = require("../request/validation");
|
|
7
|
-
const schemas_1 = require("../schemas");
|
|
8
|
-
const getDiagnosticaMethods = (makeRequest) => {
|
|
9
|
-
const getDiagnosticaHistory = validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.diagnosticaPatientFilter, zod_1.date(), zod_1.date()]), schemas_1.doc24Schemas.diagnosticaHistoryAppointment.array(), async (patient, from, to) => {
|
|
10
|
-
const path = '/history-diagnostica';
|
|
11
|
-
const response = await makeRequest('POST', path, {
|
|
12
|
-
patient: {
|
|
13
|
-
gender: patient.gender,
|
|
14
|
-
id_type: patient.identificationType === 'ndi'
|
|
15
|
-
? 'DNI'
|
|
16
|
-
: patient.identificationType,
|
|
17
|
-
id_value: patient.identificationValue,
|
|
18
|
-
},
|
|
19
|
-
dateFrom: from.toISOString(),
|
|
20
|
-
dateTo: to.toISOString(),
|
|
21
|
-
});
|
|
22
|
-
const list = response.data.info;
|
|
23
|
-
return list.map((i) => ({
|
|
24
|
-
date: new Date(Date.parse(i.date)),
|
|
25
|
-
location: i.location,
|
|
26
|
-
exams: i.exams,
|
|
27
|
-
deepLink: i.deeplink,
|
|
28
|
-
}));
|
|
29
|
-
});
|
|
30
|
-
const getDiagnosticaDeepLink = validation_1.validateFunction(zod_1.tuple([
|
|
31
|
-
zod_1.string(),
|
|
32
|
-
schemas_1.doc24Schemas.diagnosticaUser,
|
|
33
|
-
schemas_1.doc24Schemas.diagnosticaPatient,
|
|
34
|
-
]), schemas_1.doc24Schemas.diagnosticaDeepLinkResponse, async (kiosk, user, patient) => {
|
|
35
|
-
const path = '/deeplink-diagnostica';
|
|
36
|
-
const response = await makeRequest('POST', path, {
|
|
37
|
-
kiosk,
|
|
38
|
-
user: mapUserData(user),
|
|
39
|
-
patient: mapPatientData(patient),
|
|
40
|
-
});
|
|
41
|
-
const data = response.data.info.data;
|
|
42
|
-
if (data.forwarding_required)
|
|
43
|
-
return { forwardingRequired: true, deepLink: data.deeplink };
|
|
44
|
-
return { forwardingRequired: false };
|
|
45
|
-
});
|
|
46
|
-
const getDiagnosticaAccess = validation_1.validateFunction(zod_1.tuple([
|
|
47
|
-
zod_1.string(),
|
|
48
|
-
schemas_1.doc24Schemas.diagnosticaUser,
|
|
49
|
-
schemas_1.doc24Schemas.diagnosticaPatient,
|
|
50
|
-
]), zod_1.void(), async (kiosk, user, patient) => {
|
|
51
|
-
const path = '/access-diagnostica';
|
|
52
|
-
await makeRequest('POST', path, {
|
|
53
|
-
kiosk,
|
|
54
|
-
user: mapUserData(user),
|
|
55
|
-
patient: mapPatientData(patient),
|
|
56
|
-
});
|
|
57
|
-
return;
|
|
58
|
-
});
|
|
59
|
-
return { getDiagnosticaHistory, getDiagnosticaDeepLink, getDiagnosticaAccess };
|
|
60
|
-
};
|
|
61
|
-
exports.getDiagnosticaMethods = getDiagnosticaMethods;
|
|
62
|
-
const mapPatientData = (patient) => {
|
|
63
|
-
return {
|
|
64
|
-
name: patient.firstName,
|
|
65
|
-
surname: patient.lastName,
|
|
66
|
-
birthday: date_fns_1.format(patient.birthday, 'yyyy-MM-dd'),
|
|
67
|
-
id_type: 'DNI',
|
|
68
|
-
id_value: patient.identificationValue,
|
|
69
|
-
gender: patient.gender.toLocaleUpperCase(),
|
|
70
|
-
};
|
|
71
|
-
};
|
|
72
|
-
const mapUserData = (user) => {
|
|
73
|
-
return {
|
|
74
|
-
...mapPatientData(user),
|
|
75
|
-
phone: user.phone,
|
|
76
|
-
email: user.email,
|
|
77
|
-
language: user.language,
|
|
78
|
-
};
|
|
79
|
-
};
|
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
import { RequestMaker } from '../request';
|
|
2
|
-
export declare const getExternalMethods: (makeRequest: RequestMaker) => {
|
|
3
|
-
externalLogin: (params: {
|
|
4
|
-
user: string;
|
|
5
|
-
password: string;
|
|
6
|
-
}) => Promise<{
|
|
7
|
-
firstName: string;
|
|
8
|
-
lastName: string;
|
|
9
|
-
countryId: string;
|
|
10
|
-
gender: "m" | "f" | "o";
|
|
11
|
-
phone: string;
|
|
12
|
-
email: string;
|
|
13
|
-
birthday: Date;
|
|
14
|
-
identificationNumber: string;
|
|
15
|
-
}>;
|
|
16
|
-
preExternalEnrollment: (params: ({
|
|
17
|
-
birthdate: Date;
|
|
18
|
-
identificationNumber: string;
|
|
19
|
-
} & {
|
|
20
|
-
phone: string;
|
|
21
|
-
email: string;
|
|
22
|
-
}) | ({
|
|
23
|
-
birthdate: Date;
|
|
24
|
-
identificationNumber: string;
|
|
25
|
-
} & {
|
|
26
|
-
phone?: undefined;
|
|
27
|
-
email: string;
|
|
28
|
-
}) | ({
|
|
29
|
-
birthdate: Date;
|
|
30
|
-
identificationNumber: string;
|
|
31
|
-
} & {
|
|
32
|
-
email?: undefined;
|
|
33
|
-
phone: string;
|
|
34
|
-
})) => Promise<void>;
|
|
35
|
-
externalEnrollment: (params: ({
|
|
36
|
-
birthdate: Date;
|
|
37
|
-
identificationNumber: string;
|
|
38
|
-
} & {
|
|
39
|
-
phone: string;
|
|
40
|
-
email: string;
|
|
41
|
-
} & {
|
|
42
|
-
password: string;
|
|
43
|
-
} & {
|
|
44
|
-
emailCode: string;
|
|
45
|
-
phoneCode: string;
|
|
46
|
-
}) | ({
|
|
47
|
-
birthdate: Date;
|
|
48
|
-
identificationNumber: string;
|
|
49
|
-
} & {
|
|
50
|
-
phone: string;
|
|
51
|
-
email: string;
|
|
52
|
-
} & {
|
|
53
|
-
password: string;
|
|
54
|
-
} & {
|
|
55
|
-
phoneCode?: undefined;
|
|
56
|
-
emailCode: string;
|
|
57
|
-
}) | ({
|
|
58
|
-
birthdate: Date;
|
|
59
|
-
identificationNumber: string;
|
|
60
|
-
} & {
|
|
61
|
-
phone: string;
|
|
62
|
-
email: string;
|
|
63
|
-
} & {
|
|
64
|
-
password: string;
|
|
65
|
-
} & {
|
|
66
|
-
emailCode?: undefined;
|
|
67
|
-
phoneCode: string;
|
|
68
|
-
}) | ({
|
|
69
|
-
birthdate: Date;
|
|
70
|
-
identificationNumber: string;
|
|
71
|
-
} & {
|
|
72
|
-
phone?: undefined;
|
|
73
|
-
email: string;
|
|
74
|
-
} & {
|
|
75
|
-
password: string;
|
|
76
|
-
} & {
|
|
77
|
-
emailCode: string;
|
|
78
|
-
phoneCode: string;
|
|
79
|
-
}) | ({
|
|
80
|
-
birthdate: Date;
|
|
81
|
-
identificationNumber: string;
|
|
82
|
-
} & {
|
|
83
|
-
phone?: undefined;
|
|
84
|
-
email: string;
|
|
85
|
-
} & {
|
|
86
|
-
password: string;
|
|
87
|
-
} & {
|
|
88
|
-
phoneCode?: undefined;
|
|
89
|
-
emailCode: string;
|
|
90
|
-
}) | ({
|
|
91
|
-
birthdate: Date;
|
|
92
|
-
identificationNumber: string;
|
|
93
|
-
} & {
|
|
94
|
-
phone?: undefined;
|
|
95
|
-
email: string;
|
|
96
|
-
} & {
|
|
97
|
-
password: string;
|
|
98
|
-
} & {
|
|
99
|
-
emailCode?: undefined;
|
|
100
|
-
phoneCode: string;
|
|
101
|
-
}) | ({
|
|
102
|
-
birthdate: Date;
|
|
103
|
-
identificationNumber: string;
|
|
104
|
-
} & {
|
|
105
|
-
email?: undefined;
|
|
106
|
-
phone: string;
|
|
107
|
-
} & {
|
|
108
|
-
password: string;
|
|
109
|
-
} & {
|
|
110
|
-
emailCode: string;
|
|
111
|
-
phoneCode: string;
|
|
112
|
-
}) | ({
|
|
113
|
-
birthdate: Date;
|
|
114
|
-
identificationNumber: string;
|
|
115
|
-
} & {
|
|
116
|
-
email?: undefined;
|
|
117
|
-
phone: string;
|
|
118
|
-
} & {
|
|
119
|
-
password: string;
|
|
120
|
-
} & {
|
|
121
|
-
phoneCode?: undefined;
|
|
122
|
-
emailCode: string;
|
|
123
|
-
}) | ({
|
|
124
|
-
birthdate: Date;
|
|
125
|
-
identificationNumber: string;
|
|
126
|
-
} & {
|
|
127
|
-
email?: undefined;
|
|
128
|
-
phone: string;
|
|
129
|
-
} & {
|
|
130
|
-
password: string;
|
|
131
|
-
} & {
|
|
132
|
-
emailCode?: undefined;
|
|
133
|
-
phoneCode: string;
|
|
134
|
-
})) => Promise<{
|
|
135
|
-
firstName: string;
|
|
136
|
-
lastName: string;
|
|
137
|
-
countryId: string;
|
|
138
|
-
gender: "m" | "f" | "o";
|
|
139
|
-
phone: string;
|
|
140
|
-
email: string;
|
|
141
|
-
birthday: Date;
|
|
142
|
-
identificationNumber: string;
|
|
143
|
-
}>;
|
|
144
|
-
sendExternalVerificationCode: (params: {
|
|
145
|
-
birthdate: Date;
|
|
146
|
-
channel: "1" | "2";
|
|
147
|
-
identificationNumber: string;
|
|
148
|
-
}) => Promise<void>;
|
|
149
|
-
verifyExternalVerificationCode: (params: {
|
|
150
|
-
code: string;
|
|
151
|
-
birthdate: Date;
|
|
152
|
-
channel: "1" | "2";
|
|
153
|
-
identificationNumber: string;
|
|
154
|
-
}) => Promise<any>;
|
|
155
|
-
externalResetPassword: (params: ({
|
|
156
|
-
birthdate: Date;
|
|
157
|
-
password: string;
|
|
158
|
-
identificationNumber: string;
|
|
159
|
-
} & {
|
|
160
|
-
emailCode: string;
|
|
161
|
-
phoneCode: string;
|
|
162
|
-
}) | ({
|
|
163
|
-
birthdate: Date;
|
|
164
|
-
password: string;
|
|
165
|
-
identificationNumber: string;
|
|
166
|
-
} & {
|
|
167
|
-
phoneCode?: undefined;
|
|
168
|
-
emailCode: string;
|
|
169
|
-
}) | ({
|
|
170
|
-
birthdate: Date;
|
|
171
|
-
password: string;
|
|
172
|
-
identificationNumber: string;
|
|
173
|
-
} & {
|
|
174
|
-
emailCode?: undefined;
|
|
175
|
-
phoneCode: string;
|
|
176
|
-
})) => Promise<any>;
|
|
177
|
-
};
|
package/lib/baseSdk/external.js
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getExternalMethods = void 0;
|
|
4
|
-
const date_fns_1 = require("date-fns");
|
|
5
|
-
const zod_1 = require("zod");
|
|
6
|
-
const validation_1 = require("../request/validation");
|
|
7
|
-
const schemas_1 = require("../schemas");
|
|
8
|
-
const getExternalMethods = (makeRequest) => {
|
|
9
|
-
const externalLogin = async ({ user, password, }) => {
|
|
10
|
-
const path = '/external-login';
|
|
11
|
-
const response = await makeRequest('POST', path, { user, password });
|
|
12
|
-
const info = response.data.login_info;
|
|
13
|
-
return {
|
|
14
|
-
firstName: info.firstname,
|
|
15
|
-
lastName: info.lastname,
|
|
16
|
-
countryId: info.country_id,
|
|
17
|
-
birthday: new Date(Date.parse(info.birthdate)),
|
|
18
|
-
identificationNumber: info.identification_number,
|
|
19
|
-
gender: info.gender.toLowerCase(),
|
|
20
|
-
email: info.email,
|
|
21
|
-
phone: info.telephone,
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
const preExternalEnrollment = async (params) => {
|
|
25
|
-
const path = '/pre-external-enrollment';
|
|
26
|
-
await makeRequest('POST', path, {
|
|
27
|
-
identification_number: params.identificationNumber,
|
|
28
|
-
birthdate: date_fns_1.format(params.birthdate, 'yyyy-MM-dd'),
|
|
29
|
-
email: params.email,
|
|
30
|
-
telephone: params.phone,
|
|
31
|
-
});
|
|
32
|
-
return;
|
|
33
|
-
};
|
|
34
|
-
const externalEnrollment = async (params) => {
|
|
35
|
-
const path = '/external-enrollment';
|
|
36
|
-
const response = await makeRequest('POST', path, {
|
|
37
|
-
identification_number: params.identificationNumber,
|
|
38
|
-
birthdate: date_fns_1.format(params.birthdate, 'yyyy-MM-dd'),
|
|
39
|
-
email: params.email,
|
|
40
|
-
telephone: params.phone,
|
|
41
|
-
password: params.password,
|
|
42
|
-
email_code: params.emailCode,
|
|
43
|
-
telephone_code: params.phoneCode,
|
|
44
|
-
});
|
|
45
|
-
const info = response.data.info;
|
|
46
|
-
return {
|
|
47
|
-
firstName: info.firstname,
|
|
48
|
-
lastName: info.lastname,
|
|
49
|
-
countryId: info.country_id,
|
|
50
|
-
birthday: new Date(Date.parse(info.birthdate)),
|
|
51
|
-
identificationNumber: info.identification_number,
|
|
52
|
-
gender: info.gender.toLowerCase(),
|
|
53
|
-
email: info.email,
|
|
54
|
-
phone: info.telephone,
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
|
-
const sendExternalVerificationCode = async (params) => {
|
|
58
|
-
const path = '/send-external-verification-code';
|
|
59
|
-
await makeRequest('POST', path, {
|
|
60
|
-
identification_number: params.identificationNumber,
|
|
61
|
-
birthdate: date_fns_1.format(params.birthdate, 'yyyy-MM-dd'),
|
|
62
|
-
channel: params.channel,
|
|
63
|
-
});
|
|
64
|
-
return;
|
|
65
|
-
};
|
|
66
|
-
const verifyExternalVerificationCode = async (params) => {
|
|
67
|
-
const path = '/verify-external-verification-code';
|
|
68
|
-
const response = await makeRequest('POST', path, {
|
|
69
|
-
identification_number: params.identificationNumber,
|
|
70
|
-
birthdate: date_fns_1.format(params.birthdate, 'yyyy-MM-dd'),
|
|
71
|
-
channel: params.channel,
|
|
72
|
-
code: params.code,
|
|
73
|
-
});
|
|
74
|
-
return response.data;
|
|
75
|
-
};
|
|
76
|
-
const externalResetPassword = async (params) => {
|
|
77
|
-
const path = '/external-reset';
|
|
78
|
-
const response = await makeRequest('POST', path, {
|
|
79
|
-
identification_number: params.identificationNumber,
|
|
80
|
-
birthdate: date_fns_1.format(params.birthdate, 'yyyy-MM-dd'),
|
|
81
|
-
password: params.password,
|
|
82
|
-
email_code: params.emailCode,
|
|
83
|
-
telephone_code: params.phoneCode,
|
|
84
|
-
});
|
|
85
|
-
return response.data;
|
|
86
|
-
};
|
|
87
|
-
return {
|
|
88
|
-
externalLogin: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.externalLoginParams]), schemas_1.doc24Schemas.externalLoginResponse, externalLogin),
|
|
89
|
-
preExternalEnrollment: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.preExternalEnrollmentParams]), zod_1.void(), preExternalEnrollment),
|
|
90
|
-
externalEnrollment: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.externalEnrollmentParams]), schemas_1.doc24Schemas.externalLoginResponse, externalEnrollment),
|
|
91
|
-
sendExternalVerificationCode: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.sendExternalVerificationCodeParams]), zod_1.void(), sendExternalVerificationCode),
|
|
92
|
-
verifyExternalVerificationCode: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.verifyExternalVerificationCodeParams]), zod_1.any(), verifyExternalVerificationCode),
|
|
93
|
-
externalResetPassword: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.externalResetPasswordParams]), zod_1.any(), externalResetPassword),
|
|
94
|
-
};
|
|
95
|
-
};
|
|
96
|
-
exports.getExternalMethods = getExternalMethods;
|
package/lib/baseSdk/index.d.ts
DELETED