@integraciones_doc24/sdk 1.16.37 → 1.16.39

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 (48) hide show
  1. package/README.md +225 -206
  2. package/lib/baseSdk/diagnostica.d.ts +54 -54
  3. package/lib/baseSdk/diagnostica.js +82 -82
  4. package/lib/baseSdk/external.d.ts +177 -177
  5. package/lib/baseSdk/external.js +96 -96
  6. package/lib/baseSdk/index.d.ts +2 -2
  7. package/lib/baseSdk/index.js +80 -77
  8. package/lib/baseSdk/integrationError.d.ts +16 -0
  9. package/lib/baseSdk/integrationError.js +33 -0
  10. package/lib/baseSdk/user.d.ts +115 -112
  11. package/lib/baseSdk/user.js +136 -136
  12. package/lib/index.d.ts +416 -400
  13. package/lib/index.js +22 -22
  14. package/lib/request/index.d.ts +4 -4
  15. package/lib/request/index.js +32 -32
  16. package/lib/request/token.d.ts +2 -2
  17. package/lib/request/token.js +34 -34
  18. package/lib/request/validation.d.ts +10 -10
  19. package/lib/request/validation.js +28 -28
  20. package/lib/schemas.d.ts +2757 -2703
  21. package/lib/schemas.js +594 -573
  22. package/lib/types.d.ts +177 -174
  23. package/lib/types.js +2 -2
  24. package/lib/userSdk/binah.d.ts +21 -21
  25. package/lib/userSdk/binah.js +20 -20
  26. package/lib/userSdk/chat.d.ts +57 -57
  27. package/lib/userSdk/chat.js +98 -98
  28. package/lib/userSdk/external.d.ts +34 -34
  29. package/lib/userSdk/external.js +72 -72
  30. package/lib/userSdk/index.d.ts +2 -2
  31. package/lib/userSdk/index.js +33 -33
  32. package/lib/userSdk/patients.d.ts +60 -58
  33. package/lib/userSdk/patients.js +91 -89
  34. package/lib/userSdk/schedule.d.ts +59 -59
  35. package/lib/userSdk/schedule.js +90 -90
  36. package/lib/userSdk/specialties.d.ts +19 -19
  37. package/lib/userSdk/specialties.js +48 -48
  38. package/lib/userSdk/videoVisit.d.ts +225 -225
  39. package/lib/userSdk/videoVisit.js +283 -283
  40. package/lib/utils.d.ts +4 -4
  41. package/lib/utils.js +68 -68
  42. package/lib/webhook/index.d.ts +2 -2
  43. package/lib/webhook/index.js +67 -67
  44. package/lib/webhook/responses.d.ts +35 -35
  45. package/lib/webhook/responses.js +42 -42
  46. package/lib/webhook/token.d.ts +2 -2
  47. package/lib/webhook/token.js +23 -23
  48. package/package.json +37 -37
@@ -1,136 +1,136 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getUserMethods = 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 userSdk_1 = require("../userSdk");
9
- const utils_1 = require("../utils");
10
- const getUserMethods = (makeRequest, url, credentials) => {
11
- const declareUser = async ({ user, channel, code, }) => {
12
- var _a;
13
- const path = '/user';
14
- const mappedUser = {
15
- lastname: user.lastName,
16
- firstname: user.firstName,
17
- identification_type: user.identificationType,
18
- identification_value: user.identificationValue,
19
- birthdate: date_fns_1.format(user.birthdate, 'yyyy-MM-dd'),
20
- gender: (_a = user.gender) === null || _a === void 0 ? void 0 : _a.toUpperCase(),
21
- phone: user.phone,
22
- email: user.email,
23
- country_id: user.countryId,
24
- };
25
- const parsedChannel = channel ? parseInt(channel) : channel;
26
- const response = await makeRequest('POST', path, {
27
- user_data: mappedUser,
28
- channel: parsedChannel,
29
- code,
30
- });
31
- const data = response.data;
32
- if (data.ask_code)
33
- return { askCode: true, userInfo: data.user_info };
34
- return {
35
- askCode: false,
36
- userId: response.data.user_id,
37
- patientId: response.data.patient_id,
38
- };
39
- };
40
- const getUserId = async (user) => {
41
- var _a;
42
- const path = '/search-user';
43
- const mappedUser = {
44
- lastname: user.lastName,
45
- firstname: user.firstName,
46
- identification_type: user.identificationType,
47
- identification_value: user.identificationValue,
48
- birthdate: date_fns_1.format(user.birthdate, 'yyyy-MM-dd'),
49
- gender: (_a = user.gender) === null || _a === void 0 ? void 0 : _a.toUpperCase(),
50
- phone: user.phone,
51
- email: user.email,
52
- country_id: user.countryId,
53
- };
54
- const response = await makeRequest('POST', path, {
55
- user_data: mappedUser,
56
- });
57
- return response.data.user_id;
58
- };
59
- const sendVerificationCode = async (params) => {
60
- const path = '/send-verification-code';
61
- const mappedParams = {
62
- identification_type: params.identificationType,
63
- identification_value: params.identificationValue,
64
- channel: parseInt(params.channel),
65
- };
66
- await makeRequest('POST', path, mappedParams);
67
- };
68
- const getUserInstance = async (user) => {
69
- const userId = typeof user === 'number' ? user : await getUserId(user);
70
- return userSdk_1.userSdk(url, credentials, userId);
71
- };
72
- const enroll = async (params) => {
73
- var _a;
74
- const path = `/enrollment`;
75
- const mappedUser = {
76
- firstname: params.firstName,
77
- lastname: params.lastName,
78
- gender: (_a = params.gender) === null || _a === void 0 ? void 0 : _a.toUpperCase(),
79
- identification_number: params.identificationNumber,
80
- birthdate: date_fns_1.format(params.birthdate, 'yyyy-MM-dd'),
81
- email: params.email,
82
- plan: params.plan,
83
- start_date: date_fns_1.format(params.startDate, 'yyyy-MM-dd'),
84
- };
85
- await makeRequest('POST', path, {
86
- user_data: mappedUser,
87
- });
88
- };
89
- const getCoverageInfo = async (identificationValue) => {
90
- const path = `/info-coverage/${identificationValue}`;
91
- const response = await makeRequest('GET', path);
92
- const raw = response.data.info;
93
- if (!raw)
94
- return null;
95
- const mappedCoverageInfo = {
96
- financerId: raw.id_financiador,
97
- defaultAffiliationId: raw.id_afiliacion_default,
98
- plan: raw.plan,
99
- identificationNumber: raw.nro_documento,
100
- credentialNumber: raw.nro_credencial,
101
- lastName: raw.apellido,
102
- firstName: raw.nombre,
103
- birthdate: utils_1.parseDate(raw.fecha_nacimiento),
104
- financerPlanId: raw.id_financiador_plan,
105
- gender: raw.sexo.toLowerCase(),
106
- brand: raw.brand,
107
- holderIdentificationNumber: raw.nro_documento_titular,
108
- copaymentValue: raw.valor_copago,
109
- mobilePhone: raw.telefono_movil,
110
- company: raw.empresa,
111
- email: raw.email,
112
- dischargeDate: raw.fecha_alta ? utils_1.parseDateTime(raw.fecha_alta) : null,
113
- leavingDate: raw.fecha_baja ? utils_1.parseDateTime(raw.fecha_baja) : null,
114
- identificacion_tributaria: raw.identificacion_tributaria,
115
- deregistrationDate: raw.fecha_baja_padron
116
- ? utils_1.parseDateTime(raw.fecha_baja_padron)
117
- : null,
118
- authorizationCode: raw.codigo_autorizacion,
119
- authorizationCodeExpiration: raw.codigo_autorizacion_vencimiento
120
- ? utils_1.parseDateTime(raw.codigo_autorizacion_vencimiento)
121
- : null,
122
- };
123
- return mappedCoverageInfo;
124
- };
125
- return {
126
- declareUser: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.declareUserParams]), schemas_1.doc24Schemas.declareUserResponse, declareUser),
127
- getUserId: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.user]), zod_1.number(), getUserId),
128
- sendVerificationCode: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.sendVerificationCodeParams]), zod_1.void(), sendVerificationCode),
129
- getUserInstance: validation_1.validateFunction(zod_1.tuple([zod_1.union([schemas_1.doc24Schemas.user, zod_1.number()])]),
130
- // TODO: validate?
131
- zod_1.any(), getUserInstance),
132
- enroll: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.enrollmentParams]), zod_1.void(), enroll),
133
- getCoverageInfo: validation_1.validateFunction(zod_1.tuple([zod_1.string()]), schemas_1.doc24Schemas.coverageInfo, getCoverageInfo),
134
- };
135
- };
136
- exports.getUserMethods = getUserMethods;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getUserMethods = 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 userSdk_1 = require("../userSdk");
9
+ const utils_1 = require("../utils");
10
+ const getUserMethods = (makeRequest, url, credentials) => {
11
+ const declareUser = async ({ user, channel, code, }) => {
12
+ var _a;
13
+ const path = '/user';
14
+ const mappedUser = {
15
+ lastname: user.lastName,
16
+ firstname: user.firstName,
17
+ identification_type: user.identificationType,
18
+ identification_value: user.identificationValue,
19
+ birthdate: date_fns_1.format(user.birthdate, 'yyyy-MM-dd'),
20
+ gender: (_a = user.gender) === null || _a === void 0 ? void 0 : _a.toUpperCase(),
21
+ phone: user.phone,
22
+ email: user.email,
23
+ country_id: user.countryId,
24
+ };
25
+ const parsedChannel = channel ? parseInt(channel) : channel;
26
+ const response = await makeRequest('POST', path, {
27
+ user_data: mappedUser,
28
+ channel: parsedChannel,
29
+ code,
30
+ });
31
+ const data = response.data;
32
+ if (data.ask_code)
33
+ return { askCode: true, userInfo: data.user_info };
34
+ return {
35
+ askCode: false,
36
+ userId: response.data.user_id,
37
+ patientId: response.data.patient_id,
38
+ };
39
+ };
40
+ const getUserId = async (user) => {
41
+ var _a;
42
+ const path = '/search-user';
43
+ const mappedUser = {
44
+ lastname: user.lastName,
45
+ firstname: user.firstName,
46
+ identification_type: user.identificationType,
47
+ identification_value: user.identificationValue,
48
+ birthdate: date_fns_1.format(user.birthdate, 'yyyy-MM-dd'),
49
+ gender: (_a = user.gender) === null || _a === void 0 ? void 0 : _a.toUpperCase(),
50
+ phone: user.phone,
51
+ email: user.email,
52
+ country_id: user.countryId,
53
+ };
54
+ const response = await makeRequest('POST', path, {
55
+ user_data: mappedUser,
56
+ });
57
+ return response.data.user_id;
58
+ };
59
+ const sendVerificationCode = async (params) => {
60
+ const path = '/send-verification-code';
61
+ const mappedParams = {
62
+ identification_type: params.identificationType,
63
+ identification_value: params.identificationValue,
64
+ channel: parseInt(params.channel),
65
+ };
66
+ await makeRequest('POST', path, mappedParams);
67
+ };
68
+ const getUserInstance = async (user) => {
69
+ const userId = typeof user === 'number' ? user : await getUserId(user);
70
+ return userSdk_1.userSdk(url, credentials, userId);
71
+ };
72
+ const enroll = async (params) => {
73
+ var _a;
74
+ const path = `/enrollment`;
75
+ const mappedUser = {
76
+ firstname: params.firstName,
77
+ lastname: params.lastName,
78
+ gender: (_a = params.gender) === null || _a === void 0 ? void 0 : _a.toUpperCase(),
79
+ identification_number: params.identificationNumber,
80
+ birthdate: date_fns_1.format(params.birthdate, 'yyyy-MM-dd'),
81
+ email: params.email,
82
+ plan: params.plan,
83
+ start_date: date_fns_1.format(params.startDate, 'yyyy-MM-dd'),
84
+ };
85
+ await makeRequest('POST', path, {
86
+ user_data: mappedUser,
87
+ });
88
+ };
89
+ const getCoverageInfo = async (identificationValue) => {
90
+ const path = `/info-coverage/${identificationValue}`;
91
+ const response = await makeRequest('GET', path);
92
+ const raw = response.data.info;
93
+ if (!raw)
94
+ return null;
95
+ const mappedCoverageInfo = {
96
+ financerId: raw.id_financiador,
97
+ defaultAffiliationId: raw.id_afiliacion_default,
98
+ plan: raw.plan,
99
+ identificationNumber: raw.nro_documento,
100
+ credentialNumber: raw.nro_credencial,
101
+ lastName: raw.apellido,
102
+ firstName: raw.nombre,
103
+ birthdate: utils_1.parseDate(raw.fecha_nacimiento),
104
+ financerPlanId: raw.id_financiador_plan,
105
+ gender: raw.sexo.toLowerCase(),
106
+ brand: raw.brand,
107
+ holderIdentificationNumber: raw.nro_documento_titular,
108
+ copaymentValue: raw.valor_copago,
109
+ mobilePhone: raw.telefono_movil,
110
+ company: raw.empresa,
111
+ email: raw.email,
112
+ dischargeDate: raw.fecha_alta ? utils_1.parseDateTime(raw.fecha_alta) : null,
113
+ leavingDate: raw.fecha_baja ? utils_1.parseDateTime(raw.fecha_baja) : null,
114
+ identificacion_tributaria: raw.identificacion_tributaria,
115
+ deregistrationDate: raw.fecha_baja_padron
116
+ ? utils_1.parseDateTime(raw.fecha_baja_padron)
117
+ : null,
118
+ authorizationCode: raw.codigo_autorizacion,
119
+ authorizationCodeExpiration: raw.codigo_autorizacion_vencimiento
120
+ ? utils_1.parseDateTime(raw.codigo_autorizacion_vencimiento)
121
+ : null,
122
+ };
123
+ return mappedCoverageInfo;
124
+ };
125
+ return {
126
+ declareUser: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.declareUserParams]), schemas_1.doc24Schemas.declareUserResponse, declareUser),
127
+ getUserId: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.user]), zod_1.number(), getUserId),
128
+ sendVerificationCode: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.sendVerificationCodeParams]), zod_1.void(), sendVerificationCode),
129
+ getUserInstance: validation_1.validateFunction(zod_1.tuple([zod_1.union([schemas_1.doc24Schemas.user, zod_1.number()])]),
130
+ // TODO: validate?
131
+ zod_1.any(), getUserInstance),
132
+ enroll: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.enrollmentParams]), zod_1.void(), enroll),
133
+ getCoverageInfo: validation_1.validateFunction(zod_1.tuple([zod_1.string()]), schemas_1.doc24Schemas.coverageInfo, getCoverageInfo),
134
+ };
135
+ };
136
+ exports.getUserMethods = getUserMethods;