diff --git a/oauth3.account.js b/oauth3.account.js new file mode 100644 index 0000000..9f3f8ec --- /dev/null +++ b/oauth3.account.js @@ -0,0 +1,60 @@ +;(function (exports) { +'use strict'; + +var OAUTH3 = exports.OAUTH3 = exports.OAUTH3 || require('./oauth3.core.js').OAUTH3; + +OAUTH3.api['account.listCards'] = function (providerUri, opts) { + var session = opts.session; + + return OAUTH3.request({ + method: 'GET' + , url: OAUTH3.url.normalize(providerUri) + + '/api/com.daplie.payments/accounts/' + session.token.sub + '/cards' + , session: session + }).then(function (res) { + return res; + }); +}; + +OAUTH3.api['account.addCard'] = function (providerUri, opts) { + var session = opts.session; + + return OAUTH3.request({ + method: 'POST' + , url: OAUTH3.url.normalize(providerUri) + + '/api/com.daplie.payments/accounts/' + session.token.sub + '/cards' + , session: session + , data: opts.data + }).then(function (res) { + return res; + }); +}; + +OAUTH3.api['account.listAddresses'] = function (providerUri, opts) { + var session = opts.session; + + return OAUTH3.request({ + method: 'GET' + , url: OAUTH3.url.normalize(providerUri) + + '/api/com.daplie.me/accounts/' + session.token.sub + '/addresses' + , session: session + }).then(function (res) { + return res; + }); +}; + +OAUTH3.api['account.addAddress'] = function (providerUri, opts) { + var session = opts.session; + + return OAUTH3.request({ + method: 'POST' + , url: OAUTH3.url.normalize(providerUri) + + '/api/com.daplie.me/accounts/' + session.token.sub + '/addresses' + , session: session + , data: opts.addAddress + }).then(function (res) { + return res; + }); +}; + +}('undefined' !== typeof exports ? exports : window));