sysone-api-mapper 1.0.7 → 1.0.9

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.
@@ -31,7 +31,621 @@ const getInsureds_CNP = async (response) => {
31
31
  return objectMapped
32
32
  }
33
33
 
34
+ const getInsureds_CNP_Request = (inputParams) => {
35
+ return {
36
+ number: inputParams.code || undefined,
37
+ firstName: inputParams.name || undefined,
38
+ page: inputParams.page || undefined,
39
+ pageSize: inputParams.pageSize || undefined,
40
+ }
41
+ }
42
+
43
+ const postInsureds_CNP = (payload) => {
44
+ const objectMapped = {
45
+ salary: typeof payload.salary === 'string' ? payload.salary : String(payload.salary),
46
+ identification: typeof payload.identification === 'string' ? payload.identification : String(payload.identification)
47
+ }
48
+ return objectMapped;
49
+ }
50
+
51
+
52
+ const getEndorsements_CNP = async (response) => {
53
+ const objectMapped = {
54
+ values:
55
+ response.endorsements.map((e) => ({
56
+ number: e.number,
57
+ validityFrom: e.dateFrom ? moment(e.dateFrom, 'DD/MM/YYYY').toISOString() : null,
58
+ validityTo: e.dateTo ? moment(e.dateTo, 'DD/MM/YYYY').toISOString() : null,
59
+ activeDate: "N/A",
60
+ type: {
61
+ code: "N/A",
62
+ name: e.detail,
63
+ group: {
64
+ code: "N/A",
65
+ name: "N/A"
66
+ }
67
+ },
68
+ }))
69
+ ,
70
+ total: response.endorsements.length,
71
+ };
72
+
73
+ return objectMapped
74
+ }
75
+
76
+ const getPolicies_CNP = async (response) => {
77
+ const objectMapped = {
78
+ values: response.policies.map((p) => ({
79
+ number: p.number,
80
+ validityFrom: p.issueDate ? moment(p.issueDate, 'DD/MM/YYYY').toISOString() : null,
81
+ validityTo: "N/A",
82
+ ingress: p.issueDate ? moment(p.issueDate, 'DD/MM/YYYY').toISOString() : null,
83
+ holder: {
84
+ name: p.holder?.name || p.holder?.firstName,
85
+ identifications: {
86
+ values: [
87
+ {
88
+ value: p.holder?.identification?.number || null,
89
+ type: {
90
+ name: p.holder?.identification?.type?.name || null,
91
+ code: p.holder?.identification?.type?.code || null
92
+ },
93
+ default: true
94
+ }
95
+ ]
96
+ }
97
+ },
98
+ code: "N/A",
99
+ alias: "N/A",
100
+ product: {
101
+ code: p.section?.code.toString() || null,
102
+ name: p.section?.name || null,
103
+ subsection: {
104
+ name: "N/A",
105
+ code: "N/A",
106
+ section: {
107
+ name: "N/A",
108
+ code: "N/A",
109
+ }
110
+ }
111
+ },
112
+ process: {
113
+ name: p.status?.name || null,
114
+ code: "N/A"
115
+ }
116
+ })),
117
+ total: response.totalRecord || null,
118
+ };
119
+ return objectMapped;
120
+ }
121
+
122
+ const getPolicies_CNP_Request = (inputParams) => {
123
+ return {
124
+ sort: inputParams.sort || "TomadorCodigo",
125
+ orderType: inputParams.orderType || "desc",
126
+ page: inputParams.page || undefined,
127
+ pageSize: inputParams.pageSize || undefined,
128
+ allPolicies: inputParams.allPolicies || true,
129
+ }
130
+ }
131
+
132
+
133
+ const getPolicyDetail_CNP = async (response) => {
134
+ const objectMapped = {
135
+ policyData: {
136
+ number: response?.number || null,
137
+ alias: "N/A",
138
+ currency: {
139
+ name: response?.currency?.name || null,
140
+ code: response?.currency?.code || null,
141
+ mnemonic: "N/A",
142
+ symbol: response?.currency?.symbol || null
143
+ },
144
+ validity: {
145
+ type: {
146
+ name: response?.currency?.name || null,
147
+ code: response?.currency?.code || null,
148
+ months: "N/A"
149
+ },
150
+ dateFrom: response?.vigencyDateFrom ? moment(response.vigencyDateFrom, 'YYYY/MM/DD').toISOString() : null,
151
+ dateTo: response?.vigencyDateTo ? moment(response.vigencyDateTo, 'YYYY/MM/DD').toISOString() : null,
152
+ },
153
+ creationDate: response?.issueDate ? moment(response.issueDate, 'YYYY/MM/DD').toISOString() : null,
154
+ renewable: true,
155
+ process: {
156
+ name: response?.status?.name || null,
157
+ code: "N/A"
158
+ }
159
+ },
160
+ roleData: {
161
+ holder: {
162
+ partyCode: response?.holder?.code || null,
163
+ name: response?.holder?.firstName && response?.holder?.lastName
164
+ ? `${response.holder.firstName} ${response.holder.lastName}` : response?.holder?.name || null,
165
+ identification: {
166
+ value: response?.holder?.identification?.number || null,
167
+ type: {
168
+ code: response?.holder?.identification?.type?.code || null,
169
+ name: response?.holder?.identification?.type?.name || null,
170
+ }
171
+ },
172
+ },
173
+ contacts: [
174
+ {
175
+ partyCode: "N/A",
176
+ name: "N/A",
177
+ identification: {
178
+ value: "N/A",
179
+ type: {
180
+ name: "N/A",
181
+ code: "N/A"
182
+ }
183
+ },
184
+ }
185
+ ],
186
+ legalResponsible: {
187
+ partyCode: "N/A",
188
+ name: "N/A",
189
+ identification: {
190
+ value: "N/A",
191
+ type: {
192
+ name: "N/A",
193
+ code: "N/A"
194
+ }
195
+ },
196
+ }
197
+ },
198
+ collectionData: {
199
+ holderDistribution: 0,
200
+ insuredDistribution: 0,
201
+ paymentFrequency: {
202
+ name: response?.paymentMethod?.periodicity?.name || null,
203
+ code: "N/A",
204
+ },
205
+ paymentMethodData: {
206
+ cashMethodData: response?.paymentMethod?.name === "CASH" ? {
207
+ values: [
208
+ {
209
+ code: "N/A",
210
+ name: response?.currency?.name || null
211
+ }
212
+ ]
213
+ } : null,
214
+ bankAccountData: response?.paymentMethod?.name === "CBU" ? {
215
+ values: [
216
+ {
217
+ code: "BA-1",
218
+ number: "1",
219
+ cbu: response?.paymentMethod?.bankAccountNumber || null,
220
+ alias: "N/A",
221
+ currency: {
222
+ code: "N/A",
223
+ name: response?.currency?.name || null
224
+ },
225
+ bankBranch: {
226
+ name: "N/A",
227
+ code: "N/A",
228
+ bank: {
229
+ name: "N/A",
230
+ code: "N/A"
231
+ }
232
+ },
233
+ bankAccountType: {
234
+ name: "N/A",
235
+ code: "N/A"
236
+ }
237
+ }
238
+ ]
239
+ } : null,
240
+ creditCardData: response?.paymentMethod?.name === "CREDIT" ? {
241
+ values: [
242
+ {
243
+ code: "N/A",
244
+ ownerName: "N/A",
245
+ cardType: {
246
+ name: "N/A",
247
+ code: "N/A"
248
+ },
249
+ cardProvider: {
250
+ name: "N/A",
251
+ code: "N/A"
252
+ },
253
+ number: "N/A",
254
+ securityCode: "N/A",
255
+ dateTo: "N/A"
256
+ }
257
+ ]
258
+ } : null
259
+ },
260
+ },
261
+ commercialStructureData: {
262
+ data: {
263
+ name: "N/A",
264
+ code: "N/A",
265
+ version: 0,
266
+ description: "N/A",
267
+ status: {
268
+ name: "N/A",
269
+ code: "N/A"
270
+ }
271
+ },
272
+ intermediaries: {
273
+ values: [
274
+ {
275
+ code: response?.intermediary?.code?.toString() || null,
276
+ name: response?.intermediary?.name || null,
277
+ licence: "N/A",
278
+ role: {
279
+ name: "N/A",
280
+ code: "N/A"
281
+ },
282
+ status: {
283
+ name: "N/A",
284
+ code: "N/A"
285
+ }
286
+ }
287
+ ]
288
+ }
289
+ },
290
+ productData: {
291
+ name: response?.product?.name || null,
292
+ code: response?.product?.code || null,
293
+ version: 0,
294
+ subsection: {
295
+ name: "N/A",
296
+ code: "N/A",
297
+ section: {
298
+ name: response?.section?.name || null,
299
+ code: response?.section?.code || null,
300
+ }
301
+ },
302
+ status: {
303
+ name: response?.status?.name || null,
304
+ code: "N/A"
305
+ },
306
+ },
307
+ coverageData: {
308
+ coverages: response?.insured?.coverages?.map((c) => (
309
+ {
310
+ coverage: {
311
+ name: c?.name || null,
312
+ code: 'N/A',
313
+ calculatorType: {
314
+ name: "N/A",
315
+ code: "N/A"
316
+ },
317
+ type: {
318
+ name: "N/A",
319
+ code: "N/A",
320
+ },
321
+ },
322
+ values: [
323
+ {
324
+ type: {
325
+ name: "N/A",
326
+ code: "N/A"
327
+ },
328
+ maxValue: "N/A",
329
+ minValue: "N/A",
330
+ }
331
+ ],
332
+ mortalityTable: {
333
+ name: "N/A",
334
+ code: "N/A",
335
+ },
336
+ ageType: {
337
+ name: "N/A",
338
+ code: "N/A",
339
+ },
340
+ })) || []
341
+ },
342
+ expenseData: {
343
+ values: []
344
+ },
345
+ wordingData: {
346
+ wordings: []
347
+ },
348
+ termData: {
349
+ values: []
350
+ },
351
+ documentationData: {
352
+ files: [],
353
+ comments: "N/A",
354
+ },
355
+ endorsementData: {
356
+ number: response?.endorsementNumber || 0,
357
+ validityFrom: "N/A",
358
+ validityTo: "N/A",
359
+ type: {
360
+ name: "N/A",
361
+ code: "N/A",
362
+ }
363
+ },
364
+ insurableData: {
365
+ minimumQuantityInsured: 0,
366
+ estimatedDeadline: response?.insured?.entranceDate || null,
367
+ minimumAge: 0,
368
+ maximumAge: 0,
369
+ maximumQuantityInsuredByEvent: 0,
370
+ maximumAmountToIndemnify: "N/A",
371
+ insurables: response?.insured ? [{
372
+ type: {
373
+ name: response?.insured?.type?.name || null,
374
+ code: response?.insured?.type?.code || null,
375
+ },
376
+ wording: "N/A",
377
+ minimumEntryAge: 0,
378
+ maximumEntryAge: 0,
379
+ endingAgePrincipalCoverage: 0,
380
+ endingAgeAditionalCoverage: 0,
381
+ }] : null
382
+ },
383
+ };
384
+ return objectMapped;
385
+ }
386
+
387
+ const getPolicyCollectiveDetail_CNP = async (response) => {
388
+ const objectMapped = {
389
+ policyData: {
390
+ number: response?.number || null,
391
+ alias: "N/A",
392
+ currency: {
393
+ name: response?.currency?.name || null,
394
+ code: response?.currency?.code || null,
395
+ mnemonic: "N/A",
396
+ symbol: response?.currency?.symbol || null
397
+ },
398
+ validity: {
399
+ type: {
400
+ name: response?.currency?.name || null,
401
+ code: response?.currency?.code || null,
402
+ months: "N/A"
403
+ },
404
+ dateFrom: response?.vigencyDateFrom ? moment(response.vigencyDateFrom, 'YYYY/MM/DD').toISOString() : null,
405
+ dateTo: response?.vigencyDateTo ? moment(response.vigencyDateTo, 'YYYY/MM/DD').toISOString() : null,
406
+ },
407
+ creationDate: response?.issueDate ? moment(response.issueDate, 'YYYY/MM/DD').toISOString() : null,
408
+ renewable: true,
409
+ process: {
410
+ name: response?.status?.name || null,
411
+ code: "N/A"
412
+ }
413
+ },
414
+ roleData: {
415
+ holder: {
416
+ partyCode: response?.holder?.code || null,
417
+ name: response?.holder?.firstName && response?.holder?.lastName
418
+ ? `${response.holder.firstName} ${response.holder.lastName}` : response?.holder?.name || null,
419
+ identification: {
420
+ value: response?.holder?.identification?.number || null,
421
+ type: {
422
+ code: response?.holder?.identification?.type?.code || null,
423
+ name: response?.holder?.identification?.type?.name || null,
424
+ }
425
+ },
426
+ },
427
+ contacts: [
428
+ {
429
+ partyCode: "N/A",
430
+ name: "N/A",
431
+ identification: {
432
+ value: "N/A",
433
+ type: {
434
+ name: "N/A",
435
+ code: "N/A"
436
+ }
437
+ },
438
+ }
439
+ ],
440
+ legalResponsible: {
441
+ partyCode: "N/A",
442
+ name: "N/A",
443
+ identification: {
444
+ value: "N/A",
445
+ type: {
446
+ name: "N/A",
447
+ code: "N/A"
448
+ }
449
+ },
450
+ }
451
+ },
452
+ collectionData: {
453
+ holderDistribution: 0,
454
+ insuredDistribution: 0,
455
+ paymentFrequency: {
456
+ name: response?.paymentMethod?.periodicity?.name || null,
457
+ code: "N/A",
458
+ },
459
+ paymentMethodData: {
460
+ cashMethodData: response?.paymentMethod?.name === "CASH" ? {
461
+ values: [
462
+ {
463
+ code: "N/A",
464
+ name: response?.currency?.name || null
465
+ }
466
+ ]
467
+ } : null,
468
+ bankAccountData: response?.paymentMethod?.name === "CBU" ? {
469
+ values: [
470
+ {
471
+ code: "BA-1",
472
+ number: "1",
473
+ cbu: response?.paymentMethod?.bankAccountNumber || null,
474
+ alias: "N/A",
475
+ currency: {
476
+ code: "N/A",
477
+ name: response?.currency?.name || null
478
+ },
479
+ bankBranch: {
480
+ name: "N/A",
481
+ code: "N/A",
482
+ bank: {
483
+ name: "N/A",
484
+ code: "N/A"
485
+ }
486
+ },
487
+ bankAccountType: {
488
+ name: "N/A",
489
+ code: "N/A"
490
+ }
491
+ }
492
+ ]
493
+ } : null,
494
+ creditCardData: response?.paymentMethod?.name === "CREDIT" ? {
495
+ values: [
496
+ {
497
+ code: "N/A",
498
+ ownerName: "N/A",
499
+ cardType: {
500
+ name: "N/A",
501
+ code: "N/A"
502
+ },
503
+ cardProvider: {
504
+ name: "N/A",
505
+ code: "N/A"
506
+ },
507
+ number: "N/A",
508
+ securityCode: "N/A",
509
+ dateTo: "N/A"
510
+ }
511
+ ]
512
+ } : null
513
+ },
514
+ },
515
+ commercialStructureData: {
516
+ data: {
517
+ name: "N/A",
518
+ code: "N/A",
519
+ version: 0,
520
+ description: "N/A",
521
+ status: {
522
+ name: "N/A",
523
+ code: "N/A"
524
+ }
525
+ },
526
+ intermediaries: {
527
+ values: [
528
+ {
529
+ code: response?.intermediary?.code?.toString() || null,
530
+ name: response?.intermediary?.name || null,
531
+ licence: "N/A",
532
+ role: {
533
+ name: "N/A",
534
+ code: "N/A"
535
+ },
536
+ status: {
537
+ name: "N/A",
538
+ code: "N/A"
539
+ }
540
+ }
541
+ ]
542
+ }
543
+ },
544
+ productData: {
545
+ name: response?.product?.name || null,
546
+ code: response?.product?.code || null,
547
+ version: 0,
548
+ subsection: {
549
+ name: "N/A",
550
+ code: "N/A",
551
+ section: {
552
+ name: response?.section?.name || null,
553
+ code: response?.section?.code || null,
554
+ }
555
+ },
556
+ status: {
557
+ name: response?.status?.name || null,
558
+ code: "N/A"
559
+ },
560
+ },
561
+ coverageData: {
562
+ coverages: response?.insured?.coverages?.map((c) => (
563
+ {
564
+ coverage: {
565
+ name: c?.name || null,
566
+ code: 'N/A',
567
+ calculatorType: {
568
+ name: "N/A",
569
+ code: "N/A"
570
+ },
571
+ type: {
572
+ name: "N/A",
573
+ code: "N/A",
574
+ },
575
+ },
576
+ values: [
577
+ {
578
+ type: {
579
+ name: "N/A",
580
+ code: "N/A"
581
+ },
582
+ maxValue: "N/A",
583
+ minValue: "N/A",
584
+ }
585
+ ],
586
+ mortalityTable: {
587
+ name: "N/A",
588
+ code: "N/A",
589
+ },
590
+ ageType: {
591
+ name: "N/A",
592
+ code: "N/A",
593
+ },
594
+ })) || []
595
+ },
596
+ expenseData: {
597
+ values: []
598
+ },
599
+ wordingData: {
600
+ wordings: []
601
+ },
602
+ termData: {
603
+ values: []
604
+ },
605
+ documentationData: {
606
+ files: [],
607
+ comments: "N/A",
608
+ },
609
+ endorsementData: {
610
+ number: response?.endorsementNumber || 0,
611
+ validityFrom: "N/A",
612
+ validityTo: "N/A",
613
+ type: {
614
+ name: "N/A",
615
+ code: "N/A",
616
+ }
617
+ },
618
+ insurableData: {
619
+ minimumQuantityInsured: 0,
620
+ estimatedDeadline: response?.insured?.entranceDate || null,
621
+ minimumAge: 0,
622
+ maximumAge: 0,
623
+ maximumQuantityInsuredByEvent: 0,
624
+ maximumAmountToIndemnify: "N/A",
625
+ insurables: response?.insured ? [{
626
+ type: {
627
+ name: response?.insured?.type?.name || null,
628
+ code: response?.insured?.type?.code || null,
629
+ },
630
+ wording: "N/A",
631
+ minimumEntryAge: 0,
632
+ maximumEntryAge: 0,
633
+ endingAgePrincipalCoverage: 0,
634
+ endingAgeAditionalCoverage: 0,
635
+ }] : null
636
+ },
637
+ }
638
+ return objectMapped;
639
+ };
640
+
34
641
 
35
642
  export {
36
- getInsureds_CNP
643
+ getInsureds_CNP,
644
+ getInsureds_CNP_Request,
645
+ postInsureds_CNP,
646
+ getEndorsements_CNP,
647
+ getPolicies_CNP,
648
+ getPolicies_CNP_Request,
649
+ getPolicyDetail_CNP,
650
+ getPolicyCollectiveDetail_CNP
37
651
  }