Skip to content

Commit

Permalink
Merge pull request #73 from fdaciuk/improve-product-return
Browse files Browse the repository at this point in the history
Improve product return
  • Loading branch information
fdaciuk committed Feb 2, 2016
2 parents 55df19b + 7c3bb37 commit d68d317
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 8 deletions.
10 changes: 8 additions & 2 deletions docs/pt-br/products.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ Esse método retorna uma Promise. O resultado da Promise é um array de objetos,
"reference": "para Lou\u00e7a Celite - Pontto Lavabo",
"salePrice": "329.90",
"subcategory": "CJSA",
"voltage": 3
"voltage": {
"code": 3,
"description": "Does not use electricity"
}
}
]
```
Expand Down Expand Up @@ -138,6 +141,9 @@ As imagens estão no objeto `images`, e estão separadas em outros dois objetos:
needsMount: <String> TEM_MONTAGEM,
price: <String> VALOR,
salePrice: <String> VALOR_VENDA,
voltage: <Number> VOLTAGEM
voltage: {
code: <Number> VOLTAGEM,
description: <String>
}
}
```
20 changes: 19 additions & 1 deletion lib/catalog/products-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,31 @@ CatalogHelper = {
needsMount: core.stringNumberToBoolean(product.TEM_MONTAGEM),
price: product.VALOR,
salePrice: product.VALOR_VENDA,
voltage: +product.VOLTAGEM
voltage: CatalogHelper.getVoltage(product.VOLTAGEM)
};
});

return Promise.resolve(products);
},

getVoltage(voltage) {
const options = [
'Bivolt',
'110 volts',
'220 volts',
'Does not use electricity',
'380 volts',
'Rechargeable Battery',
'Battery',
'Solar Energy'
];

return {
code: +voltage,
description: options[voltage]
};
},

getImageDetails(images) {
const letters = 'abcdefghijklmnopqrstuvwxyz',
imagesKeys = Object.keys(images)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "magazine-luiza",
"version": "1.0.1",
"version": "1.1.0",
"description": "A library for Magazine Luiza API",
"main": "index.js",
"scripts": {
Expand Down
20 changes: 16 additions & 4 deletions test/mock/json/catalog-result.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@
"reference": "para Lou\u00e7a Celite - Pontto Lavabo",
"salePrice": "329.90",
"subcategory": "CJSA",
"voltage": 3
"voltage": {
"code": 3,
"description": "Does not use electricity"
}
},
{
"action": "add",
Expand Down Expand Up @@ -125,7 +128,10 @@
"reference": "12 X\u00edcaras",
"salePrice": "69.90",
"subcategory": "CAFE",
"voltage": 1
"voltage": {
"code": 1,
"description": "110 volts"
}
},
{
"action": "add",
Expand Down Expand Up @@ -189,7 +195,10 @@
"reference": "12 X\u00edcaras",
"salePrice": "69.90",
"subcategory": "CAFE",
"voltage": 2
"voltage": {
"code": 2,
"description": "220 volts"
}
},
{
"action": "add",
Expand Down Expand Up @@ -253,6 +262,9 @@
"reference": "Desligamento Autom\u00e1tico + 1 Sab\u00e3o em P\u00f3 Tixan Yp\u00ea",
"salePrice": "379.00",
"subcategory": "TANK",
"voltage": 1
"voltage": {
"code": 1,
"description": "110 volts"
}
}
]

0 comments on commit d68d317

Please sign in to comment.