diff options
| author | Jules Laplace <jules@okfoc.us> | 2015-11-25 05:59:39 -0500 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2015-11-25 05:59:39 -0500 |
| commit | cec1ab9102cc6943d7e8f77b97a69ed3925a227e (patch) | |
| tree | 797ee4d1b480504a71cd063c157c49dd633fd550 /StoneIsland/www/js | |
| parent | 0da322d7440850b854ce77e8755f97116584920e (diff) | |
update/destroy address records
Diffstat (limited to 'StoneIsland/www/js')
| -rw-r--r-- | StoneIsland/www/js/lib/account/ProfileView.js | 6 | ||||
| -rw-r--r-- | StoneIsland/www/js/lib/account/ShippingView.js | 2 | ||||
| -rw-r--r-- | StoneIsland/www/js/sdk/address.js | 44 |
3 files changed, 42 insertions, 10 deletions
diff --git a/StoneIsland/www/js/lib/account/ProfileView.js b/StoneIsland/www/js/lib/account/ProfileView.js index ad0705d3..d05ef5cd 100644 --- a/StoneIsland/www/js/lib/account/ProfileView.js +++ b/StoneIsland/www/js/lib/account/ProfileView.js @@ -31,9 +31,6 @@ var ProfileView = FormView.extend({ if (data.CurrentPassword && ! data.NewPassword) { errors.push([ "NewPassword", "Please enter your new password." ]) } if (data.NewPassword && data.NewPassword.length < 7) { errors.push([ "CurrentPassword", "New password must be 7 characters or more." ]) } if (data.Gender === "NONE") { errors.push([ "Gender", "Please supply your gender." ]) } - - data.BirthDay += "T00:00:00Z" - data.YooxLetter = data.YooxLetter || "false" }, finalize: function(data){ @@ -54,7 +51,6 @@ var ProfileView = FormView.extend({ } var submissible_data = _.pick(data, "Name Surname BirthDay Gender YooxLetter".split(" ")) - // submissible_data.idUser = auth.user_id // submissible_data.AccessToken = auth.access_token // submissible_data.Premium = "false" @@ -63,6 +59,8 @@ var ProfileView = FormView.extend({ // submissible_data.FuriganaName = "" // submissible_data.FuriganaSurname = "" // submissible_data.UserPromocode = "" + submissible_data.BirthDay += "T00:00:00Z" + submissible_data.YooxLetter = data.YooxLetter || "false" submissible_data.DataProfiling = "true" return submissible_data diff --git a/StoneIsland/www/js/lib/account/ShippingView.js b/StoneIsland/www/js/lib/account/ShippingView.js index f9089875..65a55fdc 100644 --- a/StoneIsland/www/js/lib/account/ShippingView.js +++ b/StoneIsland/www/js/lib/account/ShippingView.js @@ -34,7 +34,7 @@ var ShippingView = FormView.extend({ document.body.className = "shipping" }, - save: function(){ + finalize: function(){ }, })
\ No newline at end of file diff --git a/StoneIsland/www/js/sdk/address.js b/StoneIsland/www/js/sdk/address.js index f4e36376..4fb12ad0 100644 --- a/StoneIsland/www/js/sdk/address.js +++ b/StoneIsland/www/js/sdk/address.js @@ -1,6 +1,23 @@ sdk.address = (function(){ var address = {} + address.list = function(opt){ + return $.ajax({ + method: "GET", + url: sdk.path("Account.API/1.5", "users/" + auth.user_id + "/addressBook.json"), + headers: { + "x-yoox-appname": auth.appname, + "x-yoox-account-token": auth.access_token, + }, + data: opt.data, + success: function(data){ + // console.log(data) + opt.success(data) + }, + error: opt.error, + }) + } + address.add = function(opt){ return $.ajax({ method: "POST", @@ -18,15 +35,15 @@ sdk.address = (function(){ }) } - address.list = function(opt){ + address.update = function(opt){ return $.ajax({ - method: "GET", - url: sdk.path("Account.API/1.5", "users/" + auth.user_id + "/addressBook.json"), + method: "PUT", + url: sdk.path("Account.API/1.5", "users/" + auth.user_id + "/addressBook/item.json"), headers: { "x-yoox-appname": auth.appname, "x-yoox-account-token": auth.access_token, }, - data: opt.data, + data: JSON.stringify( opt.data ), success: function(data){ // console.log(data) opt.success(data) @@ -34,7 +51,24 @@ sdk.address = (function(){ error: opt.error, }) } - + + address.destroy = function(opt){ + return $.ajax({ + method: "DELETE", + url: sdk.path("Account.API/1.5", "users/" + auth.user_id + "/" + opt.id + "/addressBook.json"), + headers: { + "x-yoox-appname": auth.appname, + "x-yoox-account-token": auth.access_token, + }, + data: JSON.stringify( opt.data ), + success: function(data){ + // console.log(data) + opt.success(data) + }, + error: opt.error, + }) + } + return address })()
\ No newline at end of file |
