@integraciones_doc24/sdk 1.8.2 → 1.9.0

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 CHANGED
@@ -73,14 +73,14 @@ type SdkParams = {
73
73
  credentials: SdkCredentials;
74
74
  };
75
75
  type BaseSdk = {
76
- declareUser: (params: DeclareUserParams) => Promise<any>;
76
+ declareUser: (params: DeclareUserParams) => Promise<DeclareUserResponse>;
77
77
  getUserId: (user: User) => Promise<number>;
78
78
  getUserInstance: (user: User | number) => Promise<UserSdk>;
79
79
  getProfessional: (professionalId: number) => Promise<Professional>;
80
80
  getAvailableScheduleClinics: () => Promise<AvailableScheduleClinics>;
81
81
  enroll: (params: EnrollmentParams) => Promise<void>;
82
82
  getCoverageInfo: (identificationValue: string) => Promise<CoverageInfo>;
83
- getVerificationCode: (params: VerificationCodeParams) => Promise<void>;
83
+ sendVerificationCode: (params: SendVerificationCodeParams) => Promise<void>;
84
84
  getDiagnosticaHistory: (
85
85
  patient: DiagnosticaPatientFilter,
86
86
  from: Date,
@@ -96,6 +96,20 @@ type BaseSdk = {
96
96
  user: DiagnosticaUser,
97
97
  patient: DiagnosticaPatient,
98
98
  ) => Promise<void>;
99
+ externalLogin: (
100
+ params: ExternalLoginParams,
101
+ ) => Promise<ExternalLoginResponse>;
102
+ preExternalEnrollment: (params: PreExternalEnrollmentParams) => Promise<void>;
103
+ externalEnrollment: (
104
+ params: ExternalEnrollmentParams,
105
+ ) => Promise<ExternalLoginResponse>;
106
+ sendExternalVerificationCode: (
107
+ params: SendExternalVerificationCodeParams,
108
+ ) => Promise<void>;
109
+ verifyExternalVerificationCode: (
110
+ params: VerifyExternalVerificationCodeParams,
111
+ ) => Promise<any>;
112
+ externalResetPassword: (params: ExternalResetPasswordParams) => Promise<any>;
99
113
  };
100
114
 
101
115
  type RequestHandlerParams = {
@@ -31,7 +31,7 @@ export declare const getExternalMethods: (makeRequest: RequestMaker) => {
31
31
  } & {
32
32
  email?: undefined;
33
33
  phone: string;
34
- })) => Promise<any>;
34
+ })) => Promise<void>;
35
35
  externalEnrollment: (params: ({
36
36
  birthdate: Date;
37
37
  identificationNumber: string;
@@ -131,8 +131,23 @@ export declare const getExternalMethods: (makeRequest: RequestMaker) => {
131
131
  } & {
132
132
  emailCode?: undefined;
133
133
  phoneCode: string;
134
- })) => Promise<any>;
135
- getExternalVerificationCode: (params: {
134
+ })) => Promise<{
135
+ firstName: string;
136
+ lastName: string;
137
+ countryId: string;
138
+ gender: "m" | "f";
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<any>;
149
+ verifyExternalVerificationCode: (params: {
150
+ code: string;
136
151
  birthdate: Date;
137
152
  channel: "1" | "2";
138
153
  identificationNumber: string;
@@ -16,7 +16,7 @@ const getExternalMethods = (makeRequest) => {
16
16
  countryId: info.country_id,
17
17
  birthday: new Date(Date.parse(info.birthdate)),
18
18
  identificationNumber: info.identification_number,
19
- gender: info.gender === 'F' ? 'f' : 'm',
19
+ gender: info.gender.toLowerCase(),
20
20
  email: info.email,
21
21
  phone: info.telephone,
22
22
  };
@@ -42,9 +42,19 @@ const getExternalMethods = (makeRequest) => {
42
42
  email_code: params.emailCode,
43
43
  telephone_code: params.phoneCode,
44
44
  });
45
- return response.data;
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
+ };
46
56
  };
47
- const getExternalVerificationCode = async (params) => {
57
+ const sendExternalVerificationCode = async (params) => {
48
58
  const path = '/send-external-verification-code';
49
59
  await makeRequest('POST', path, {
50
60
  identification_number: params.identificationNumber,
@@ -53,6 +63,16 @@ const getExternalMethods = (makeRequest) => {
53
63
  });
54
64
  return;
55
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
+ };
56
76
  const externalResetPassword = async (params) => {
57
77
  const path = '/external-reset';
58
78
  const response = await makeRequest('POST', path, {
@@ -66,9 +86,10 @@ const getExternalMethods = (makeRequest) => {
66
86
  };
67
87
  return {
68
88
  externalLogin: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.externalLoginParams]), schemas_1.doc24Schemas.externalLoginResponse, externalLogin),
69
- preExternalEnrollment: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.preExternalEnrollmentParams]), zod_1.any(), preExternalEnrollment),
70
- externalEnrollment: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.externalEnrollmentParams]), zod_1.any(), externalEnrollment),
71
- getExternalVerificationCode: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.externalVerificationCodeParams]), zod_1.any(), getExternalVerificationCode),
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.any(), sendExternalVerificationCode),
92
+ verifyExternalVerificationCode: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.verifyExternalVerificationCodeParams]), zod_1.any(), verifyExternalVerificationCode),
72
93
  externalResetPassword: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.externalResetPasswordParams]), zod_1.any(), externalResetPassword),
73
94
  };
74
95
  };
@@ -38,7 +38,7 @@ export declare const getUserMethods: (makeRequest: RequestMaker, url: string, cr
38
38
  phone: string;
39
39
  email: string;
40
40
  }) => Promise<number>;
41
- getVerificationCode: (params: {
41
+ sendVerificationCode: (params: {
42
42
  identificationType: number;
43
43
  identificationValue: string;
44
44
  channel: "1" | "2";
@@ -60,8 +60,8 @@ export declare const getUserMethods: (makeRequest: RequestMaker, url: string, cr
60
60
  birthdate: Date;
61
61
  gender: "m" | "f";
62
62
  email: string;
63
- startDate: Date;
64
63
  identificationNumber: string;
64
+ startDate: Date;
65
65
  plan: string;
66
66
  }) => Promise<void>;
67
67
  getCoverageInfo: (identificationValue: string) => Promise<{
@@ -54,7 +54,7 @@ const getUserMethods = (makeRequest, url, credentials) => {
54
54
  });
55
55
  return response.data.user_id;
56
56
  };
57
- const getVerificationCode = async (params) => {
57
+ const sendVerificationCode = async (params) => {
58
58
  const path = '/send-verification-code';
59
59
  const mappedParams = {
60
60
  identification_type: params.identificationType,
@@ -120,7 +120,7 @@ const getUserMethods = (makeRequest, url, credentials) => {
120
120
  return {
121
121
  declareUser: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.declareUserParams]), schemas_1.doc24Schemas.declareUserResponse, declareUser),
122
122
  getUserId: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.user]), zod_1.number(), getUserId),
123
- getVerificationCode: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.verificationCodeParams]), zod_1.void(), getVerificationCode),
123
+ sendVerificationCode: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.sendVerificationCodeParams]), zod_1.void(), sendVerificationCode),
124
124
  getUserInstance: validation_1.validateFunction(zod_1.tuple([zod_1.union([schemas_1.doc24Schemas.user, zod_1.number()])]),
125
125
  // TODO: validate?
126
126
  zod_1.any(), getUserInstance),
package/lib/index.d.ts CHANGED
@@ -102,8 +102,8 @@ export declare const doc24Sdk: (params: Doc24.SdkParams) => Promise<{
102
102
  birthdate: Date;
103
103
  gender: "m" | "f";
104
104
  email: string;
105
- startDate: Date;
106
105
  identificationNumber: string;
106
+ startDate: Date;
107
107
  plan: string;
108
108
  }) => Promise<void>;
109
109
  getCoverageInfo: (identificationValue: string) => Promise<{
@@ -130,7 +130,7 @@ export declare const doc24Sdk: (params: Doc24.SdkParams) => Promise<{
130
130
  authorizationCode: string | null;
131
131
  authorizationCodeExpiration: Date | null;
132
132
  } | null>;
133
- getVerificationCode: (params: {
133
+ sendVerificationCode: (params: {
134
134
  identificationType: number;
135
135
  identificationValue: string;
136
136
  channel: "1" | "2";
@@ -317,12 +317,27 @@ export declare const doc24Sdk: (params: Doc24.SdkParams) => Promise<{
317
317
  } & {
318
318
  emailCode?: undefined;
319
319
  phoneCode: string;
320
- })) => Promise<any>;
321
- getExternalVerificationCode: (params: {
320
+ })) => Promise<{
321
+ firstName: string;
322
+ lastName: string;
323
+ countryId: string;
324
+ gender: "m" | "f";
325
+ phone: string;
326
+ email: string;
327
+ birthday: Date;
328
+ identificationNumber: string;
329
+ }>;
330
+ sendExternalVerificationCode: (params: {
322
331
  birthdate: Date;
323
332
  channel: "1" | "2";
324
333
  identificationNumber: string;
325
334
  }) => Promise<void>;
335
+ verifyExternalVerificationCode: (params: {
336
+ code: string;
337
+ birthdate: Date;
338
+ channel: "1" | "2";
339
+ identificationNumber: string;
340
+ }) => Promise<any>;
326
341
  externalResetPassword: (params: ({
327
342
  birthdate: Date;
328
343
  password: string;
package/lib/schemas.d.ts CHANGED
@@ -935,8 +935,8 @@ export declare const doc24Schemas: {
935
935
  birthdate: Date;
936
936
  gender: "m" | "f";
937
937
  email: string;
938
- startDate: Date;
939
938
  identificationNumber: string;
939
+ startDate: Date;
940
940
  plan: string;
941
941
  }, {
942
942
  firstName: string;
@@ -944,8 +944,8 @@ export declare const doc24Schemas: {
944
944
  birthdate: Date;
945
945
  gender: "m" | "f";
946
946
  email: string;
947
- startDate: Date;
948
947
  identificationNumber: string;
948
+ startDate: Date;
949
949
  plan: string;
950
950
  }>;
951
951
  diagnosticaPatientFilter: import("zod").ZodObject<{
@@ -1117,7 +1117,7 @@ export declare const doc24Schemas: {
1117
1117
  authorizationCode: string | null;
1118
1118
  authorizationCodeExpiration: Date | null;
1119
1119
  }>>;
1120
- verificationCodeParams: import("zod").ZodObject<{
1120
+ sendVerificationCodeParams: import("zod").ZodObject<{
1121
1121
  identificationType: import("zod").ZodNumber;
1122
1122
  identificationValue: import("zod").ZodString;
1123
1123
  channel: import("zod").ZodEnum<["1", "2"]>;
@@ -1334,7 +1334,7 @@ export declare const doc24Schemas: {
1334
1334
  patientId: number | null;
1335
1335
  askCode: false;
1336
1336
  }>]>;
1337
- verificationParams: import("zod").ZodObject<{
1337
+ verificationCodeParams: import("zod").ZodObject<{
1338
1338
  channel: import("zod").ZodOptional<import("zod").ZodEnum<["1", "2"]>>;
1339
1339
  code: import("zod").ZodOptional<import("zod").ZodString>;
1340
1340
  }, "strip", import("zod").ZodTypeAny, {
@@ -1516,7 +1516,7 @@ export declare const doc24Schemas: {
1516
1516
  emailCode?: undefined;
1517
1517
  phoneCode: string;
1518
1518
  }>>;
1519
- externalVerificationCodeParams: import("zod").ZodObject<{
1519
+ sendExternalVerificationCodeParams: import("zod").ZodObject<{
1520
1520
  identificationNumber: import("zod").ZodString;
1521
1521
  birthdate: import("zod").ZodDate;
1522
1522
  channel: import("zod").ZodEnum<["1", "2"]>;
@@ -1529,6 +1529,23 @@ export declare const doc24Schemas: {
1529
1529
  channel: "1" | "2";
1530
1530
  identificationNumber: string;
1531
1531
  }>;
1532
+ verifyExternalVerificationCodeParams: import("zod").ZodObject<import("zod").extendShape<{
1533
+ identificationNumber: import("zod").ZodString;
1534
+ birthdate: import("zod").ZodDate;
1535
+ channel: import("zod").ZodEnum<["1", "2"]>;
1536
+ }, {
1537
+ code: import("zod").ZodString;
1538
+ }>, "strip", import("zod").ZodTypeAny, {
1539
+ code: string;
1540
+ birthdate: Date;
1541
+ channel: "1" | "2";
1542
+ identificationNumber: string;
1543
+ }, {
1544
+ code: string;
1545
+ birthdate: Date;
1546
+ channel: "1" | "2";
1547
+ identificationNumber: string;
1548
+ }>;
1532
1549
  externalResetPasswordParams: import("zod").ZodIntersection<import("zod").ZodObject<{
1533
1550
  identificationNumber: import("zod").ZodString;
1534
1551
  birthdate: import("zod").ZodDate;
package/lib/schemas.js CHANGED
@@ -175,21 +175,21 @@ const coverageInfo = zod_1.object({
175
175
  authorizationCode: zod_1.string().nullable(),
176
176
  authorizationCodeExpiration: zod_1.date().nullable(),
177
177
  }).nullable();
178
- const verificationCodeParams = zod_1.object({
178
+ const sendVerificationCodeParams = zod_1.object({
179
179
  identificationType: zod_1.number(),
180
180
  identificationValue: zod_1.string(),
181
181
  channel: zod_1.enum(['1', '2']),
182
182
  });
183
- const verificationParams = zod_1.object({
183
+ const verificationCodeParams = zod_1.object({
184
184
  channel: zod_1.enum(['1', '2']).optional(),
185
185
  code: zod_1.string().optional(),
186
186
  });
187
187
  const declareUserParams = zod_1.object({
188
188
  user,
189
- }).and(verificationParams);
189
+ }).and(verificationCodeParams);
190
190
  const declarePatientParams = zod_1.object({
191
191
  patient,
192
- }).and(verificationParams);
192
+ }).and(verificationCodeParams);
193
193
  const declarePatientResponse = zod_1.object({
194
194
  userInfo: zod_1.object({
195
195
  firstName: zod_1.string(),
@@ -244,11 +244,12 @@ const emailOrPhoneCode = zod_1.union([
244
244
  const externalEnrollmentParams = preExternalEnrollmentParams
245
245
  .and(zod_1.object({ password: zod_1.string() }))
246
246
  .and(emailOrPhoneCode);
247
- const externalVerificationCodeParams = zod_1.object({
247
+ const sendExternalVerificationCodeParams = zod_1.object({
248
248
  identificationNumber: zod_1.string(),
249
249
  birthdate: zod_1.date(),
250
250
  channel: zod_1.enum(['1', '2']),
251
251
  });
252
+ const verifyExternalVerificationCodeParams = sendExternalVerificationCodeParams.extend({ code: zod_1.string() });
252
253
  const externalResetPasswordParams = zod_1.object({
253
254
  identificationNumber: zod_1.string(),
254
255
  birthdate: zod_1.date(),
@@ -373,16 +374,17 @@ exports.doc24Schemas = {
373
374
  diagnosticaPatient,
374
375
  diagnosticaDeepLinkResponse,
375
376
  coverageInfo,
376
- verificationCodeParams,
377
+ sendVerificationCodeParams,
377
378
  declareUserParams,
378
379
  declareUserResponse,
379
380
  declarePatientParams,
380
381
  declarePatientResponse,
381
- verificationParams,
382
+ verificationCodeParams,
382
383
  externalLoginParams,
383
384
  externalLoginResponse,
384
385
  preExternalEnrollmentParams,
385
386
  externalEnrollmentParams,
386
- externalVerificationCodeParams,
387
+ sendExternalVerificationCodeParams,
388
+ verifyExternalVerificationCodeParams,
387
389
  externalResetPasswordParams,
388
390
  };
package/lib/types.d.ts CHANGED
@@ -29,17 +29,18 @@ export declare namespace Doc24 {
29
29
  type DiagnosticaPatient = TypeOf<typeof doc24Schemas.diagnosticaPatient>;
30
30
  type DiagnosticaHistoryAppointment = TypeOf<typeof doc24Schemas.diagnosticaHistoryAppointment>;
31
31
  type DiagnosticaDeepLinkResponse = TypeOf<typeof doc24Schemas.diagnosticaDeepLinkResponse>;
32
- type VerificationCodeParams = TypeOf<typeof doc24Schemas.verificationCodeParams>;
32
+ type SendVerificationCodeParams = TypeOf<typeof doc24Schemas.sendVerificationCodeParams>;
33
33
  type DeclareUserParams = TypeOf<typeof doc24Schemas.declareUserParams>;
34
34
  type DeclareUserResponse = TypeOf<typeof doc24Schemas.declareUserResponse>;
35
35
  type DeclarePatientParams = TypeOf<typeof doc24Schemas.declarePatientParams>;
36
36
  type DeclarePatientResponse = TypeOf<typeof doc24Schemas.declarePatientResponse>;
37
- type VerificationParams = TypeOf<typeof doc24Schemas.verificationParams>;
37
+ type VerificationCodeParams = TypeOf<typeof doc24Schemas.verificationCodeParams>;
38
38
  type ExternalLoginParams = TypeOf<typeof doc24Schemas.externalLoginParams>;
39
39
  type ExternalLoginResponse = TypeOf<typeof doc24Schemas.externalLoginResponse>;
40
40
  type PreExternalEnrollmentParams = TypeOf<typeof doc24Schemas.preExternalEnrollmentParams>;
41
41
  type ExternalEnrollmentParams = TypeOf<typeof doc24Schemas.externalEnrollmentParams>;
42
- type ExternalVerificationCodeParams = TypeOf<typeof doc24Schemas.externalVerificationCodeParams>;
42
+ type SendExternalVerificationCodeParams = TypeOf<typeof doc24Schemas.sendExternalVerificationCodeParams>;
43
+ type VerifyExternalVerificationCodeParams = TypeOf<typeof doc24Schemas.verifyExternalVerificationCodeParams>;
43
44
  type ExternalResetPasswordParams = TypeOf<typeof doc24Schemas.externalResetPasswordParams>;
44
45
  type BaseSdk = {
45
46
  declareUser: (params: DeclareUserParams) => Promise<DeclareUserResponse>;
@@ -49,14 +50,15 @@ export declare namespace Doc24 {
49
50
  getAvailableScheduleClinics: () => Promise<AvailableScheduleClinics>;
50
51
  enroll: (params: EnrollmentParams) => Promise<void>;
51
52
  getCoverageInfo: (identificationValue: string) => Promise<CoverageInfo>;
52
- getVerificationCode: (params: VerificationCodeParams) => Promise<void>;
53
+ sendVerificationCode: (params: SendVerificationCodeParams) => Promise<void>;
53
54
  getDiagnosticaHistory: (patient: DiagnosticaPatientFilter, from: Date, to: Date) => Promise<DiagnosticaHistoryAppointment[]>;
54
55
  getDiagnosticaDeepLink: (kiosk: string, user: DiagnosticaUser, patient: DiagnosticaPatient) => Promise<DiagnosticaDeepLinkResponse>;
55
56
  getDiagnosticaAccess: (kiosk: string, user: DiagnosticaUser, patient: DiagnosticaPatient) => Promise<void>;
56
57
  externalLogin: (params: ExternalLoginParams) => Promise<ExternalLoginResponse>;
57
58
  preExternalEnrollment: (params: PreExternalEnrollmentParams) => Promise<void>;
58
- externalEnrollment: (params: ExternalEnrollmentParams) => Promise<any>;
59
- getExternalVerificationCode: (params: ExternalVerificationCodeParams) => Promise<void>;
59
+ externalEnrollment: (params: ExternalEnrollmentParams) => Promise<ExternalLoginResponse>;
60
+ sendExternalVerificationCode: (params: SendExternalVerificationCodeParams) => Promise<void>;
61
+ verifyExternalVerificationCode: (params: VerifyExternalVerificationCodeParams) => Promise<any>;
60
62
  externalResetPassword: (params: ExternalResetPasswordParams) => Promise<any>;
61
63
  };
62
64
  type UserSdk = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@integraciones_doc24/sdk",
3
- "version": "1.8.2",
3
+ "version": "1.9.0",
4
4
  "publishConfig": {
5
5
  "tag": "latest"
6
6
  },