summaryrefslogtreecommitdiff
path: root/StoneIsland/platforms/ios/www/js/sdk/account.js
diff options
context:
space:
mode:
Diffstat (limited to 'StoneIsland/platforms/ios/www/js/sdk/account.js')
-rw-r--r--StoneIsland/platforms/ios/www/js/sdk/account.js54
1 files changed, 54 insertions, 0 deletions
diff --git a/StoneIsland/platforms/ios/www/js/sdk/account.js b/StoneIsland/platforms/ios/www/js/sdk/account.js
new file mode 100644
index 00000000..a1498e76
--- /dev/null
+++ b/StoneIsland/platforms/ios/www/js/sdk/account.js
@@ -0,0 +1,54 @@
+sdk.account = (function(){
+
+ var user_id, access_token
+
+ // https://gist.github.com/fanfare/d18498e7fa25acbd4486
+ var account = {}
+ account.signup = function(opt){
+ $.ajax({
+ method: "POST",
+ url: sdk.path("Account.API/1.5", "users.json"),
+ headers: {
+ "x-yoox-appname": auth.appname,
+ "x-yoox-api-key": auth.apikey,
+ },
+ data: opt.data,
+ success: function(data){
+ console.log(data)
+ user_id = data['UserAccount']['UserId']
+ access_token = data['UserAccount']['AccessToken']
+
+ auth.set_user(user_id, access_token, name)
+
+ opt.success(data)
+ },
+ error: opt.error,
+ })
+ }
+
+ account.login = function(opt){
+ $.ajax({
+ method: "POST",
+ url: sdk.path("Account.API/1.5", "authfull.json"),
+ headers: {
+ "x-yoox-appname": auth.appname,
+ "x-yoox-account-token": auth.access_token,
+ },
+ data: opt.data,
+ success: function(data){
+ console.log(data)
+ auth.user_id = data['UserAccount']['UserId']
+ auth.access_token = data['UserAccount']['AccessToken']
+
+ // why bother?
+ // auth.set_user(user_id, access_token, name)
+
+ opt.success(data)
+ },
+ error: opt.error,
+ })
+ }
+
+ return account
+
+})()