summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--StoneIsland/www/js/sdk/cart.js19
-rw-r--r--StoneIsland/www/js/sdk/shipping.js3
-rw-r--r--proxy/index.js15
-rw-r--r--test/test/04-cart.js45
4 files changed, 47 insertions, 35 deletions
diff --git a/StoneIsland/www/js/sdk/cart.js b/StoneIsland/www/js/sdk/cart.js
index 98669fbd..b10503d8 100644
--- a/StoneIsland/www/js/sdk/cart.js
+++ b/StoneIsland/www/js/sdk/cart.js
@@ -54,7 +54,7 @@ sdk.cart = (function(){
},
data: opt.data,
success: function(data){
- console.log(data)
+ // console.log(data)
opt.success(data)
},
error: opt.error,
@@ -65,14 +65,15 @@ sdk.cart = (function(){
return $.ajax({
method: "DELETE",
url: sdk.path("Cart.API/1.6", "carts/" + cart.id +
- "/items/" + opt.code10 +
- "/" + opt.size + ".json"),
+ "/items/" + opt.data.Code10 +
+ "/" + opt.data.Size + ".json"),
headers: {
"x-yoox-appname": auth.appname,
"x-yoox-cart-token": cart.token,
},
+ data: {},
success: function(data){
- console.log(data)
+ // console.log(data)
opt.success(data)
},
error: opt.error,
@@ -82,18 +83,14 @@ sdk.cart = (function(){
cart.get_status = function(opt){
return $.ajax({
method: "GET",
- url: sdk.path("Cart.API/1.6", "carts/" + cart.id + "/user.json"),
+ url: sdk.path("Cart.API/1.6", "carts/" + cart.id + ".json"),
headers: {
"x-yoox-appname": auth.appname,
"x-yoox-cart-token": cart.token,
"x-yoox-device": auth.device,
},
- data: {
- "UserId": auth.user_id,
- "UserToken": auth.access_token,
- },
success: function(data){
- console.log(data)
+ // console.log(data)
opt.success(data)
},
error: opt.error,
@@ -111,7 +108,7 @@ sdk.cart = (function(){
},
data: opt.data,
success: function(data){
- console.log(data)
+ // console.log(data)
opt.success(data)
},
error: opt.error,
diff --git a/StoneIsland/www/js/sdk/shipping.js b/StoneIsland/www/js/sdk/shipping.js
index 709d2594..95f78d82 100644
--- a/StoneIsland/www/js/sdk/shipping.js
+++ b/StoneIsland/www/js/sdk/shipping.js
@@ -15,8 +15,7 @@ sdk.shipping = (function() {
"x-yoox-cart-token": sdk.cart.token,
},
success: function(data){
- //opt.success(data['BoxTypes']['Types'])
- //opt.success(data)
+ // console.log(data)
opt.success(data)
},
error: opt.error,
diff --git a/proxy/index.js b/proxy/index.js
index 80cd6d4b..d84d3813 100644
--- a/proxy/index.js
+++ b/proxy/index.js
@@ -37,6 +37,10 @@ server.on('request', function (req, res){
options.hostname = 'secure.api.yoox.biz'
options.path = req.url
+if (req.method == "DELETE") {
+ console.log(options.headers)
+ console.log(req.url)
+}
req.pause()
var connector = https.request(options, function(server_res) {
console.log('>> GOT', server_res.statusCode)
@@ -58,6 +62,15 @@ server.on('request', function (req, res){
server_res.resume()
})
+ connector.on('response', function(e){
+ console.log(">> RESPONSE")
+ })
+ connector.on('connect', function(e){
+ console.log(">> CONNECT")
+ })
+ connector.on('error', function(e){
+ console.error(e)
+ })
if (DEBUG) {
req.on('data', function(s){ console.log('>>', s.toString()) })
}
@@ -85,7 +98,7 @@ function get_headers (h){
})
hh['Content-Type'] = 'application/json' // h['content-type']
if ('content-length' in h) hh['Content-Length'] = h['content-length']
- if ('connection' in h) hh['Connection'] = h['connection']
+ // if ('connection' in h) hh['Connection'] = h['connection']
return hh
}
diff --git a/test/test/04-cart.js b/test/test/04-cart.js
index f2304a26..55736b39 100644
--- a/test/test/04-cart.js
+++ b/test/test/04-cart.js
@@ -40,25 +40,32 @@ describe('cart', function(){
})
describe('#add_item()', function(){
- /*
it('adds item to cart', function(done){
var product_item = {
"Code10": "37725683OV",
- "Size": 2,
- "Section": "",
- }
+ "Size": 4,
+ }
promise(sdk.cart.add_item, { data: product_item }).then(function(data){
- assert(data.Header.StatusCode == 200)
+ assert(data.Header.StatusCode == 201)
done()
})
})
- */
})
describe('#delete_item()', function(){
+ it('removes item from cart', function(done){
+ var product_item = {
+ "Code10": "37725683OV",
+ "Size": 4,
+ }
+ promise(sdk.cart.delete_item, { data: product_item }).then(function(data){
+ // console.log(data)
+ assert(data.Header.StatusCode == 200)
+ done()
+ })
+ })
})
describe('#get_status()', function(){
-
it('get contents of cart', function(done){
var user_creds = {
"UserId": sdk.auth.user_id,
@@ -66,12 +73,10 @@ describe('cart', function(){
}
promise(sdk.cart.get_status, { data: user_creds }).then(function(data){
assert(data.Header.StatusCode == 200)
+ // console.log(data)
done()
})
})
-
-
-
})
})
@@ -87,18 +92,16 @@ describe('shipping', function(){
describe('#set_shipping_address()', function(){
it('set shipping address', function(done){
var shipping_info = {
- "Name":"Nome SecondoNome",
- "Surname":"Cognome SecondoCognome",
- "Phone":"333333333",
- "CareOf":"Care of",
+ "Name":"Nome",
+ "Surname":"Cognome",
"Email":"prova@prova.it",
- "Mobile":"333333333",
- "VatNumber":"VatNumber",
- "StreetWithNumber":"StreetNumber",
- "Region":"Region",
- "PostalCode":"88040",
- "City":"City",
- "CountryCode":"IT",
+ "Phone":"333-333-3333",
+ "Mobile":"333-333-3333",
+ "StreetWithNumber":"555 StreetNumber\nBlah Blah",
+ "PostalCode":"11101",
+ "City":"Long Island City",
+ "Region":"NY",
+ "CountryCode":"US",
}
promise(sdk.cart.set_shipping_address, { data: shipping_info }).then(function(data){
assert(data.Header.StatusCode == 200)