@integraciones_doc24/sdk 1.16.22 → 1.16.23
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/utils.d.ts +1 -0
- package/lib/utils.js +13 -1
- package/lib/webhook/index.js +4 -2
- package/package.json +1 -1
package/lib/utils.d.ts
CHANGED
package/lib/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseDateTime = exports.parseDate = void 0;
|
|
3
|
+
exports.normalizeTimezoneOffset = exports.parseDateTime = exports.parseDate = void 0;
|
|
4
4
|
const date_fns_1 = require("date-fns");
|
|
5
5
|
// import {Doc24} from '.';
|
|
6
6
|
const defaultTimeZone = '-03';
|
|
@@ -8,6 +8,18 @@ const parseDate = (str, timeZone) => exports.parseDateTime(`${str} 00:00:00`, ti
|
|
|
8
8
|
exports.parseDate = parseDate;
|
|
9
9
|
const parseDateTime = (str, timeZone) => date_fns_1.parse(`${str} ${timeZone !== null && timeZone !== void 0 ? timeZone : defaultTimeZone}`, 'yyyy-MM-dd HH:mm:ss X', new Date());
|
|
10
10
|
exports.parseDateTime = parseDateTime;
|
|
11
|
+
const normalizeTimezoneOffset = (raw) => {
|
|
12
|
+
const match = raw.trim().match(/^([+-]?)(\d{1,2})/);
|
|
13
|
+
if (!match) {
|
|
14
|
+
throw new Error(`Invalid timezone format: ${raw}`);
|
|
15
|
+
}
|
|
16
|
+
let [, sign, hours] = match;
|
|
17
|
+
if (!sign)
|
|
18
|
+
sign = '+';
|
|
19
|
+
const paddedHours = hours.padStart(2, '0');
|
|
20
|
+
return `${sign}${paddedHours}`;
|
|
21
|
+
};
|
|
22
|
+
exports.normalizeTimezoneOffset = normalizeTimezoneOffset;
|
|
11
23
|
// export const getIdetificationTypeId = (type: Doc24.IdentificationType) => {
|
|
12
24
|
// if (type === 'ndi') return 6;
|
|
13
25
|
// if (type === 'passport') return 5;
|
package/lib/webhook/index.js
CHANGED
|
@@ -28,7 +28,8 @@ const handleEvent = async (body, _baseSdk, eventHandlers) => {
|
|
|
28
28
|
vcToken: body.vc_token,
|
|
29
29
|
patientId: body.id_paciente !== undefined ? Number(body.id_paciente) : undefined,
|
|
30
30
|
});
|
|
31
|
-
if (body.tipo === 'invitacion')
|
|
31
|
+
if (body.tipo === 'invitacion') {
|
|
32
|
+
const normalizedTimeZone = utils_1.normalizeTimezoneOffset(body.user_time_zone);
|
|
32
33
|
return (_b = eventHandlers.onInvitationStatusChange) === null || _b === void 0 ? void 0 : _b.call(eventHandlers, {
|
|
33
34
|
status: body.id_estado,
|
|
34
35
|
changeDate: date,
|
|
@@ -41,11 +42,12 @@ const handleEvent = async (body, _baseSdk, eventHandlers) => {
|
|
|
41
42
|
identificationValue: body.valor_identificacion,
|
|
42
43
|
idSharedVc: body.id_shared_vc,
|
|
43
44
|
specialtyId: body.id_especialidad,
|
|
44
|
-
date: utils_1.parseDateTime(`${body.fecha_turno} ${body.hora_turno}`,
|
|
45
|
+
date: utils_1.parseDateTime(`${body.fecha_turno} ${body.hora_turno}`, normalizedTimeZone),
|
|
45
46
|
appointmentDate: body.fecha_turno,
|
|
46
47
|
appointmentTime: body.hora_turno,
|
|
47
48
|
userTimeZone: body.user_time_zone,
|
|
48
49
|
});
|
|
50
|
+
}
|
|
49
51
|
if (body.tipo === 'turno')
|
|
50
52
|
return (_c = eventHandlers.onAppointmentStatusChange) === null || _c === void 0 ? void 0 : _c.call(eventHandlers, {
|
|
51
53
|
id: Number(body.id_turno),
|