-
Notifications
You must be signed in to change notification settings - Fork 0
/
b2w_pedidos.js
75 lines (70 loc) · 2.64 KB
/
b2w_pedidos.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
const config = require('./b2w_config');
const request = require('request');
class b2w_pedidos {
constructor() {
}
criarPedidoTeste() {
request({
url: 'https://api.skyhub.com.br/orders',
method: 'POST',
headers: config.preparaHeaders(),
json: true,
body: {
"order": {
"channel": "Marketplace",
"items": [
{
"id": "10200487",
"qty": 1,
"original_price": 8.45,
"special_price": 8.45
}
],
"customer": {
"name": "Nome do comprador",
"email": "[email protected]",
"date_of_birth": "1995-01-01",
"gender": "male",
"vat_number": "12312312309",
"phones": [
"8899999999"
]
},
"billing_address": {
"street": "Rua de teste",
"number": 1234,
"detail": "Ponto de referência teste",
"neighborhood": "Bairro teste",
"city": "Cidade de teste",
"region": "UF",
"country": "BR",
"postcode": "90000000"
},
"shipping_address": {
"street": "Rua de teste",
"number": 1234,
"detail": "Ponto de referência teste",
"neighborhood": "Bairro teste",
"city": "Cidade de teste",
"region": "UF",
"country": "BR",
"postcode": "90000000"
},
"shipping_method": "Transportadora",
"estimated_delivery": "2015-01-10",
"shipping_calculation_type": "Método do Cálculo",
"shipping_cost": 5,
"interest": 0,
"discount": 0
}
}
}, function (error, response, body) {
if (response.statusCode == 201 || response.statusCode == 200 || response.statusCode == 204) {
console.log(body);
} else {
console.log('Error => ' + JSON.stringify(body));
}
});
}
}
module.exports = b2w_pedidos;