From 7741621c16c53efafdd248a1e3a28c8e9ba94cf9 Mon Sep 17 00:00:00 2001 From: Drew Warren Date: Wed, 12 Apr 2017 16:44:16 -0600 Subject: [PATCH] Add Account API for Cards/Addresses --- oauth3.account.js | 60 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 oauth3.account.js 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));