sysone-api-mapper 1.0.126 → 1.0.128

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sysone-api-mapper",
3
- "version": "1.0.126",
3
+ "version": "1.0.128",
4
4
  "description": "Paquete mapper para portal de productores",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -10,6 +10,7 @@ import {
10
10
  getMaritalStatuses,
11
11
  getProductsBySubsections_Request,
12
12
  getProvinces,
13
+ partySearch,
13
14
  partySearchParams
14
15
  } from "./modules/party";
15
16
  import {
@@ -352,7 +353,7 @@ const partyModule = {
352
353
  method: methods.GET,
353
354
  source: "https://developers-test.cnp.com.ar/api-details#api=party-api&operation=get-v1-parties",
354
355
  requestMapper: request => ({ mappedParams: partySearchParams(request) }),
355
- responseMapper: (response) => response.data,
356
+ responseMapper: (response) => partySearch(response.data),
356
357
  },
357
358
  },
358
359
 
@@ -66,10 +66,45 @@ export const partySearchParams = (params) => {
66
66
  return {
67
67
  firstName: params.firstName || null,
68
68
  lastName: params.lastName || null,
69
- identification: params.identificationValue || null,
69
+ identification: params.holderPartyCode || null,
70
70
  }
71
71
  }
72
72
 
73
+ export const partySearch = (res) => {
74
+ const objectMapped = {
75
+ values: res?.parties?.map(party => {
76
+
77
+ // Separación por doble espacio
78
+ const [lastNamePart, firstNamePart] = party?.fullName?.split(" ") || [];
79
+
80
+ return {
81
+ activeDate: party?.activeDate || null,
82
+ partyCode: party?.code || null,
83
+ code: party?.party?.identification?.value || null,
84
+ firstName: firstNamePart || null,
85
+ lastName: lastNamePart || null,
86
+ identifications: {
87
+ values: [
88
+ {
89
+ default: true,
90
+ type: {
91
+ code: "",
92
+ name: "",
93
+ },
94
+ value: party?.identification?.value || null,
95
+ }
96
+ ]
97
+ },
98
+ birthDate: party?.birthDate,
99
+ insuredCode: party?.insuredCode
100
+ };
101
+ })
102
+ };
103
+
104
+ return objectMapped;
105
+ };
106
+
107
+
73
108
  export const getCoverages = (p) => {
74
109
  const objectMapped = {
75
110
  coverages: p.coverages?.map(c => ({