sysone-api-mapper 1.0.47 → 1.0.48

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.47",
3
+ "version": "1.0.48",
4
4
  "description": "Paquete mapper para portal de productores",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -1,20 +1,20 @@
1
1
  import { mapPaymentFrequency, mapProductCode } from "../../helpers/mappingHelpers";
2
2
 
3
3
  export const getQuotationsList = async (response) => {
4
- const objectMapped = {
5
- quotations: response.quotations.map(q => ({
4
+ const quotations = Array.isArray(response?.quotations)
5
+ ? response.quotations.map(q => ({
6
6
  code: q.code || null,
7
7
  creationDate: q.creationDate || null,
8
8
  email: q.email || null,
9
9
  expirationDate: q.expirationDate || null,
10
10
  number: q.number || null,
11
11
  paymentFrequency: {
12
- name: q.paymentFrequency.name || null,
13
- code: q.paymentFrequency.code || null,
12
+ name: q.paymentFrequency?.name || null,
13
+ code: q.paymentFrequency?.code || null,
14
14
  },
15
15
  product: {
16
- code: q.product?.code.toString() || null,
17
- name: q.product?.name,
16
+ code: q.product?.code?.toString() || null,
17
+ name: q.product?.name || null,
18
18
  subsection: {
19
19
  code: q.product?.subsection?.code || null,
20
20
  name: q.product?.subsection?.name || null,
@@ -26,13 +26,18 @@ export const getQuotationsList = async (response) => {
26
26
  version: q.product?.version || 0,
27
27
  },
28
28
  status: {
29
- code: q.status.code || null,
30
- name: q.status.name || null,
29
+ code: q.status?.code || null,
30
+ name: q.status?.name || null,
31
31
  },
32
- })),
33
- total: response.total || null,
32
+ }))
33
+ : [];
34
+
35
+ const total = response?.total ? response.total : 0;
36
+
37
+ return {
38
+ quotations,
39
+ total,
34
40
  };
35
- return objectMapped;
36
41
  };
37
42
 
38
43
  export const getQuotationByCode = async (response) => {