sysone-api-mapper 1.0.37 → 1.0.39

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.37",
3
+ "version": "1.0.39",
4
4
  "description": "Paquete mapper para portal de productores",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -38,7 +38,6 @@ const configs = {
38
38
  headers: {
39
39
  ["X-Channel"]: API_MAPPER.cnp.headers["X-Chanel"],
40
40
  ["X-Agent"]: API_MAPPER.cnp.headers["X-Agent"],
41
- ["X-Client"]: API_MAPPER.cnp.headers["X-Client"],
42
41
  ["Ocp-Apim-Subscription-Key"]: API_MAPPER.cnp.headers["Ocp-Apim-Subscription-Key"],
43
42
  ["X-Origin"]: "sysone-api-mapper"
44
43
  },
@@ -75,6 +74,11 @@ export const apiMapper = async (
75
74
  ...additionalHeaders,
76
75
  }
77
76
  }
77
+
78
+ // Validar que se haya proporcionado X-Client
79
+ if (!config.headers["X-Client"]) {
80
+ throw new Error("Header X-Client es requerido para requests CNP");
81
+ }
78
82
  } else {
79
83
  // Para cualquier otro tenant, usar config default pero sobreescribir X-Tenant y X-User
80
84
  config = {
@@ -1,7 +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, getMaritalStatuses, getProductsBySubsections_Request, getProvinces } from "./modules/party";
4
+ import { getCountries, getGenders, getIdentificationTypes, getMaritalStatuses, getProductsBySubsections_Request, getProvinces } from "./modules/party";
5
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";
6
6
  import { getActivityList, getPaymentFrecuencies, getProductsBySubsections, getQuotationByCode, getQuotationByCode_Request, getQuotations_Request, getQuotationsList, quotationStandardPlanCreationMapped, quotationVariablePlanCreationMapped } from "./modules/quotation";
7
7
 
@@ -33,6 +33,54 @@ export const tenantsConfig = {
33
33
 
34
34
  //------------ PARTY ---------------------------
35
35
 
36
+ GET_CURRENCIES: {
37
+ default: {
38
+ url: 'finance/v1/currencies',
39
+ method: methods.GET,
40
+ requestMapper: (request) => ({ mappedParams: request }),
41
+ responseMapper: (response) => response,
42
+ },
43
+ cnp: {
44
+ url: 'party/v1/currencies',
45
+ method: methods.GET,
46
+ source: "https://developers-test.cnp.com.ar/api-details#api=party-api&operation=get-v1-currencies",
47
+ requestMapper: request => ({ mappedParams: request }),
48
+ responseMapper: (response) => response,
49
+ },
50
+ },
51
+ GET_GENDERS: {
52
+ default: {
53
+ url: 'party/v1/genders',
54
+ method: methods.GET,
55
+ source: 'https://apidoc.sysone.com/party/v1/open-api.html#/paths/~1v1~1genders/get',
56
+ requestMapper: (request) => ({ mappedParams: request }),
57
+ responseMapper: (response) => response,
58
+ },
59
+ cnp: {
60
+ url: 'party/v1/genders',
61
+ method: methods.GET,
62
+ requestMapper: request => ({ mappedParams: request }),
63
+ responseMapper: (response) => getGenders(response),
64
+ },
65
+ },
66
+ GET_COVERAGES: {
67
+ cnp: {
68
+ url: 'party/v1/products/{0}/coverages',
69
+ method: methods.GET,
70
+ source: "https://developers-test.cnp.com.ar/api-details#api=party-api&operation=get-v1-products-code-coverages-currencycode-currencycode-smoker-smoker",
71
+ requestMapper: request => ({ mappedParams: request }),
72
+ responseMapper: (response) => response,
73
+ },
74
+ },
75
+ GET_DISTRIBUTION_LIMITS: {
76
+ cnp: {
77
+ url: 'party/v1/products/{0}/savings-distribution',
78
+ method: methods.GET,
79
+ source: "https://developers-test.cnp.com.ar/api-details#api=party-api&operation=get-v1-products-code-coverages-currencycode-currencycode-smoker-smoker",
80
+ requestMapper: request => ({ mappedParams: request }),
81
+ responseMapper: (response) => response,
82
+ },
83
+ },
36
84
  GET_IDENTIFICATION_TYPES: {
37
85
  default: {
38
86
  url: 'party/v1/identification-types',
@@ -313,6 +361,7 @@ export const tenantsConfig = {
313
361
  responseMapper: (response) => getPolicyDetail_CNP(response),
314
362
  },
315
363
  },
364
+ //--------------------------------------- QUOTATION ------------------------------------------------------
316
365
  GET_QUOTATION_BY_CODE: {
317
366
  default: {
318
367
  url: 'quotation/v1/quotations/{0}',
@@ -338,14 +387,12 @@ export const tenantsConfig = {
338
387
  responseMapper: (response) => response
339
388
  },
340
389
  cnp: {
341
- url: 'quotation/v1/quotation/variable-plan',
390
+ url: 'quotation/v1/quotations',
342
391
  method: methods.GET,
343
- source: 'https://developers-test.cnp.com.ar/api-details#api=quotation-api&operation=get-v1-quotation-variable-plan',
344
392
  requestMapper: request => ({ mappedParams: getQuotations_Request(request) }),
345
393
  responseMapper: (response) => getQuotationsList(response)
346
394
  }
347
395
  },
348
- GET_PAYMENT_METHODS: {},
349
396
 
350
397
  //------------- POST -----------------------------
351
398
  POST_INSURED_UPDATE: {
@@ -420,6 +467,14 @@ export const tenantsConfig = {
420
467
  responseMapper: (response) => response,
421
468
  }
422
469
  },
470
+ POST_CALCULATE_LS: {
471
+ cnp: {
472
+ url: 'quotation/v1/quotations/calculate',
473
+ method: methods.POST,
474
+ requestMapper: (params) => ({ mappedBody: params }),
475
+ responseMapper: (response) => response,
476
+ }
477
+ },
423
478
 
424
479
  //------------- PUT ------------------------------
425
480
  CREATE_INSURED: {
@@ -46,6 +46,16 @@ export const getMaritalStatuses = async (response) => {
46
46
  return objectMapped;
47
47
  }
48
48
 
49
+ export const getGenders = async (response) => {
50
+ const objectMapped = {
51
+ values: response.genders.map(a => ({
52
+ name: a.name,
53
+ code: a.code,
54
+ })),
55
+ }
56
+ return objectMapped;
57
+ }
58
+
49
59
  export const getProductsBySubsections_Request = (params) => {
50
60
  return {
51
61
  subsectionCode: null
@@ -3,34 +3,34 @@ import { mapPaymentFrequency, mapProductCode } from "../../helpers/mappingHelper
3
3
  export const getQuotationsList = async (response) => {
4
4
  const objectMapped = {
5
5
  quotations: response.quotations.map(q => ({
6
- code: "N/A",
7
- creationDate: "N/A",
8
- email: "N/A",
9
- expirationDate: "N/A",
10
- number: q.quotationNumber || null,
6
+ code: q.code || null,
7
+ creationDate: q.creationDate || null,
8
+ email: q.email || null,
9
+ expirationDate: q.expirationDate || null,
10
+ number: q.number || null,
11
11
  paymentFrequency: {
12
- name: "N/A",
13
- code: "N/A",
12
+ name: q.paymentFrequency.name || null,
13
+ code: q.paymentFrequency.code || null,
14
14
  },
15
15
  product: {
16
- code: q.productCode?.toString() || null,
17
- name: "N/A",
16
+ code: q.product?.code.toString() || null,
17
+ name: q.product?.name,
18
18
  subsection: {
19
- code: "N/A",
20
- name: "N/A",
19
+ code: q.product?.subsection?.code || null,
20
+ name: q.product?.subsection?.name || null,
21
21
  section: {
22
- code: q.sectionCode?.toString() || null,
23
- name: "N/A",
22
+ code: q.product?.subsection?.section?.code || null,
23
+ name: q.product?.subsection?.section?.name || null,
24
24
  }
25
25
  },
26
- version: 0,
26
+ version: q.product?.version || 0,
27
27
  },
28
28
  status: {
29
- code: "N/A",
30
- name: "N/A",
29
+ code: q.status.code || null,
30
+ name: q.status.name || null,
31
31
  },
32
32
  })),
33
- total: 'N/A',
33
+ total: response.total || null,
34
34
  };
35
35
  return objectMapped;
36
36
  };