sysone-api-mapper 1.0.29 → 1.0.31

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.29",
3
+ "version": "1.0.31",
4
4
  "description": "Paquete mapper para portal de productores",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -5,11 +5,23 @@ import dotenv from "dotenv";
5
5
  // Cargar variables de entorno
6
6
  dotenv.config();
7
7
 
8
- // Obtener y parsear la configuración del archivo .env
9
- const API_MAPPER = process.env.API_MAPPER || {};
10
- // Acceder específicamente a la configuración de api-mapper
8
+ const getApiMapperConfig = () => {
9
+ // 1. Intentar desde variables de entorno compiladas
10
+ if (process.env.API_MAPPER && Object.keys(process.env.API_MAPPER).length > 0) {
11
+ console.log("Usando API_MAPPER de process.env");
12
+ return process.env.API_MAPPER;
13
+ }
14
+
15
+ // 2. Intentar desde variable global inyectada
16
+ if (window.__API_MAPPER__ && Object.keys(window.__API_MAPPER__).length > 0) {
17
+ console.log("Usando API_MAPPER de window");
18
+ return window.__API_MAPPER__;
19
+ }
20
+
21
+ };
11
22
 
12
- console.log("variable API_MAPPER desde Paquete de sysone", API_MAPPER);
23
+ const API_MAPPER = getApiMapperConfig();
24
+ console.log("Configuración API_MAPPER cargada:", API_MAPPER);
13
25
 
14
26
  const configs = {
15
27
  default: {
@@ -1,6 +1,7 @@
1
1
  // import { methods } from "./mapper";
2
2
  import { getClaims_CNP } from "./modules/claim";
3
3
  import { getModules, getModules_Request } from "./modules/general";
4
+ import { getCountries, getIdentificationTypes, getProvinces } from "./modules/party";
4
5
  import { getEndorsements_CNP, getEndorsements_Request, getInsureds_CNP, getInsureds_CNP_Request, getPolicies_CNP, getPolicies_CNP_Request, getPolicyCollectiveDetail_CNP, getPolicyCollectiveDetail_Request, getPolicyDetail_CNP, getPolicyIndividualDetail_Request, postInsureds_CNP } from "./modules/policy";
5
6
  import { getActivityList, getQuotationByCode, getQuotationByCode_Request, getQuotations_Request, getQuotationsList, quotationStandardPlanCreationMapped, quotationVariablePlanCreationMapped } from "./modules/quotation";
6
7
 
@@ -29,6 +30,76 @@ export const tenantsConfig = {
29
30
  },
30
31
 
31
32
  //------------------------------------------------
33
+
34
+ //------------ PARTY ---------------------------
35
+
36
+ GET_IDENTIFICATION_TYPES: {
37
+ default: {
38
+ url: 'party/v1/sectors',
39
+ method: methods.GET,
40
+ source: 'https://apidoc.sysone.com/party/v1/open-api.html#/paths/~1v1~1identification-types/get',
41
+ requestMapper: (request) => ({ mappedParams: request }),
42
+ responseMapper: (response) => response,
43
+ },
44
+ cnp: {
45
+ url: 'party/v1/identification-types',
46
+ method: methods.GET,
47
+ source: "https://developers-test.cnp.com.ar/api-details#api=party-api&operation=get-v1-identification-types",
48
+ requestMapper: request => ({ mappedParams: request }),
49
+ responseMapper: (response) => getIdentificationTypes(response),
50
+ },
51
+ },
52
+ GET_COUNTRIES: {
53
+ default: {
54
+ url: 'location/v1/countries',
55
+ method: methods.GET,
56
+ source: 'https://apidoc.sysone.com/location/v1/open-api.html#/paths/~1v1~1countries/get',
57
+ requestMapper: (request) => ({ mappedParams: request }),
58
+ responseMapper: (response) => response,
59
+ },
60
+ cnp: {
61
+ url: 'party/v1/countries',
62
+ method: methods.GET,
63
+ source: "https://developers-test.cnp.com.ar/api-details#api=party-api&operation=get-v1-countries",
64
+ requestMapper: request => ({ mappedParams: request }),
65
+ responseMapper: (response) => getCountries(response),
66
+ },
67
+ },
68
+
69
+ GET_PROVINCES: {
70
+ default: {
71
+ url: 'location/v1/countries/{0}/provinces',
72
+ method: methods.GET,
73
+ source: 'https://apidoc.sysone.com/location/v1/open-api.html#/paths/~1v1~1countries/get',
74
+ requestMapper: (request) => ({ mappedParams: request }),
75
+ responseMapper: (response) => response,
76
+ },
77
+ cnp: {
78
+ url: 'party/v1/countries/{0}/provinces',
79
+ method: methods.GET,
80
+ source: "https://developers-test.cnp.com.ar/api-details#api=party-api&operation=get-v1-countries",
81
+ requestMapper: request => ({ mappedParams: request }),
82
+ responseMapper: (response) => getProvinces(response),
83
+ },
84
+ },
85
+
86
+ GET_MARITAL_STATUS: {
87
+ default: {
88
+ url: 'party/v1/marital-statuses',
89
+ method: methods.GET,
90
+ source: 'https://apidoc.sysone.com/party/v1/open-api.html#/paths/~1v1~1marital-statuses/get',
91
+ requestMapper: (request) => ({ mappedParams: request }),
92
+ responseMapper: (response) => response,
93
+ },
94
+ cnp: {
95
+ url: 'party/v1/marital-statuses',
96
+ method: methods.GET,
97
+ source: "https://developers-test.cnp.com.ar/api-details#api=party-api&operation=get-v1-marital-statuses",
98
+ requestMapper: request => ({ mappedParams: request }),
99
+ responseMapper: (response) => getMaritalStatuses(response),
100
+ },
101
+ },
102
+
32
103
  GET_ACTIVITY: {
33
104
  default: {
34
105
  url: 'party/v1/sectors',
@@ -0,0 +1,47 @@
1
+
2
+
3
+ export const getIdentificationTypes = async (response) => {
4
+ const objectMapped = {
5
+ values: response.types.map(a => ({
6
+ code: a.code,
7
+ name: a.name,
8
+ })),
9
+ }
10
+ return objectMapped;
11
+ }
12
+
13
+ export const getCountries = async (response) => {
14
+ const objectMapped = {
15
+ countries: response.countries.map(a => ({
16
+ code: a.code,
17
+ name: a.name,
18
+ areaCode: 'N/A'
19
+ })),
20
+ }
21
+ return objectMapped;
22
+ }
23
+
24
+ export const getProvinces = async (response) => {
25
+ const objectMapped = {
26
+ provinces: response.provinces.map(a => ({
27
+ name: a.name,
28
+ code: a.code,
29
+ country: {
30
+ code: a.country.code,
31
+ name: a.country.name,
32
+ areaCode: "N/A"
33
+ }
34
+ })),
35
+ }
36
+ return objectMapped;
37
+ }
38
+
39
+ export const getMaritalStatuses = async (response) => {
40
+ const objectMapped = {
41
+ values: response.statuses.map(a => ({
42
+ name: a.name,
43
+ code: a.code,
44
+ })),
45
+ }
46
+ return objectMapped;
47
+ }