diff options
| author | Jules Laplace <jules@okfoc.us> | 2015-09-25 14:52:44 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2015-09-25 14:52:44 -0400 |
| commit | 365e6c93c1a57bb45d2ea274218378f642b4d425 (patch) | |
| tree | 6b22b1a9e26a9fa8883e3148f0547dbb3404cd7e /StoneIsland/www/js/sdk/account.js | |
| parent | 7acf0f1f7f7af782981e6001370f46c4dd7460d2 (diff) | |
split up api
Diffstat (limited to 'StoneIsland/www/js/sdk/account.js')
| -rw-r--r-- | StoneIsland/www/js/sdk/account.js | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/StoneIsland/www/js/sdk/account.js b/StoneIsland/www/js/sdk/account.js new file mode 100644 index 00000000..40ba1d67 --- /dev/null +++ b/StoneIsland/www/js/sdk/account.js @@ -0,0 +1,48 @@ +sdk.account = (function(){ + + // 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: sdk.headers, + 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) + + sdk.headers['x-yoox-account-token'] = access_token + + opt.success(data) + }, + error: opt.error, + }) + } + + account.login = function(opt){ + // TODO: fetch access token from storage + $.ajax({ + method: "POST", + url: sdk.path("Account.API/1.5", "authfull.json"), + headers: sdk.headers, + 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, + }) + } + + return account + +})() |
