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)); diff --git a/oauth3.dns.js b/oauth3.dns.js index abc139e..e81f9c5 100644 --- a/oauth3.dns.js +++ b/oauth3.dns.js @@ -31,15 +31,23 @@ OAUTH3.api['devices.list'] = function (providerUri, opts) { OAUTH3.api['devices.attach'] = function (providerUri, opts) { var session = opts.session; + var device = opts.device; + var tld = opts.tld; + var sld = opts.sld; + var sub = opts.sub; + var ip = opts.ip; + var ttl = opts.ttl; return OAUTH3.request({ url: OAUTH3.url.normalize(providerUri) - + '/api/com.daplie.domains/accounts/' + session.token.sub - //+ '/devices/' + device + '/' - + '/devices/' + (opts.data.uid || '_') + '/' + opts.data.device - + '/' + opts.data.tld + '/' + opts.data.sld + '/' + (opts.data.sub || '') + + '/api/com.daplie.domains/accounts/' + session.token.sub + '/devices/' + + device + '/' + tld + '/' + sld + '/' + (sub || '') , method: 'POST' , session: session + , data: { + addresses: ip + , ttl: ttl + } }, {}).then(function (res) { return res.data.devices || res.data; }); @@ -47,28 +55,15 @@ OAUTH3.api['devices.attach'] = function (providerUri, opts) { OAUTH3.api['devices.detach'] = function (providerUri, opts) { var session = opts.session; + var device = opts.device; + var tld = opts.tld; + var sld = opts.sld; + var sub = opts.sub; return OAUTH3.request({ url: OAUTH3.url.normalize(providerUri) + '/api/com.daplie.domains/accounts/' + session.token.sub - //+ '/devices/' + device + '/' - + '/devices/' + (opts.data.uid || '_') + '/' + opts.data.device - + '/' + opts.data.tld + '/' + opts.data.sld + '/' + (opts.data.sub || '') - , method: 'DELETE' - , session: session - }, {}).then(function (res) { - return res.data.devices || res.data; - }); -}; - -OAUTH3.api['devices.detach'] = function (providerUri, opts) { - var session = opts.session; - - return OAUTH3.request({ - url: OAUTH3.url.normalize(providerUri) - + '/api/com.daplie.domains/accounts/' + session.token.sub - + '/devices/' + opts.data.device - + '/' + opts.data.tld + '/' + opts.data.sld + '/' + (opts.data.sub || '') + + '/devices/' + device + '/' + tld + '/' + sld + '/' + (sub || '') , method: 'DELETE' , session: session }, {}).then(function (res) { @@ -76,4 +71,54 @@ OAUTH3.api['devices.detach'] = function (providerUri, opts) { }); }; +OAUTH3.api['dns.set'] = function (providerUri, opts) { + var session = opts.session; + var tld = opts.tld; + var sld = opts.sld; + var sub = opts.sub; + var type = opts.selected; + var value = opts.value; + var ttl = opts.ttl; + var priority = (opts.priority || ''); + var weight = (opts.weight || ''); + var port = (opts.port || ''); + + return OAUTH3.request({ + url: OAUTH3.url.normalize(providerUri) + + '/api/com.daplie.domains/accounts/' + session.token.sub + + '/dns/' + tld + '/' + sld + '/' + sub + , method: 'POST' + , session: session + , data: [{ + type: type + , value: value + , ttl: ttl + , priority: priority + , weight: weight + , port: port + }] + }, {}).then(function (res) { + return res.data || res; + }); +}; + +OAUTH3.api['dns.unset'] = function (providerUri, opts) { + var session = opts.session; + var tld = opts.tld; + var sld = opts.sld; + var sub = (opts.sub || '@'); + var type = opts.type; + var value = opts.value; + + return OAUTH3.request({ + url: OAUTH3.url.normalize(providerUri) + + '/api/com.daplie.domains/accounts/' + session.token.sub + + '/dns/' + tld + '/' + sld + '/' + sub + '/' + type + '/' + value + , method: 'DELETE' + , session: session + }, {}).then(function (res) { + return res.data || res; + }); +}; + }('undefined' !== typeof exports ? exports : window)); diff --git a/oauth3.domains.js b/oauth3.domains.js index f38ae75..2b5b0b0 100644 --- a/oauth3.domains.js +++ b/oauth3.domains.js @@ -3,6 +3,35 @@ var OAUTH3 = exports.OAUTH3 = exports.OAUTH3 || require('./oauth3.core.js').OAUTH3; +OAUTH3.api['domains.checkAvailability'] = function (providerUri, opts) { + var session = opts.session; + var sld = opts.sld; + var tld = opts.tld; + + return OAUTH3.request({ + method: 'GET' + , url: OAUTH3.url.normalize(providerUri) + + '/api/com.daplie.domains/check-availability/' + sld + '/' + tld + , session: session + }).then(function (res) { + return res; + }); +}; + +OAUTH3.api['domains.purchase'] = function (providerUri, opts) { + var session = opts.session; + + return OAUTH3.request({ + method: 'POST' + , url: OAUTH3.url.normalize(providerUri) + + '/api/com.daplie.domains/accounts/' + session.token.sub + '/registrations' + , session: session + , data: opts.data + }).then(function (res) { + return res; + }); +}; + OAUTH3.api['domains.list'] = function (providerUri, opts) { var session = opts.session; @@ -16,4 +45,86 @@ OAUTH3.api['domains.list'] = function (providerUri, opts) { }); }; +OAUTH3.api['ns.list'] = function (providerUri, opts) { + var session = opts.session; + var domain = opts.domain; + var nameArr = domain.split('.'); + var reverseNameArr = nameArr.reverse(); + var nameSubArr = reverseNameArr.slice(3); + var tld; + var sld; + var sub; + + if (reverseNameArr[0] === 'me' && reverseNameArr[1] === 'daplie') { + tld = 'daplie.me'; + sld = reverseNameArr[2]; + sub = nameSubArr.reverse().join('.') || ''; + } else { + tld = nameArr[0]; + sld = nameArr[1]; + sub = reverseNameArr.slice(2).reverse().join('.') || ''; + } + + return OAUTH3.request({ + method: 'GET' + , url: OAUTH3.url.normalize(providerUri) + + '/api/com.daplie.domains/accounts/' + session.token.sub + '/ns/' + + tld + '/' + sld + '/' + sub + , session: session + }).then(function (res) { + return res.data; + }); +}; + +OAUTH3.api['ns.add'] = function (providerUri, opts) { + var session = opts.session + var server = opts.server; + var tld = opts.tld; + var sld = opts.sld; + var sub = opts.sub; + + return OAUTH3.request({ + method: 'POST' + , url: OAUTH3.url.normalize(providerUri) + + '/api/com.daplie.domains/accounts/' + session.token.sub + '/ns/' + + tld + '/' + sld + '/' + sub + , session: session + , data: { nameservers: [server] } + }).then(function (res) { + return res; + }); +}; + +OAUTH3.api['glue.list'] = function (providerUri, opts) { + var session = opts.session; + + return OAUTH3.request({ + method: 'GET' + , url: OAUTH3.url.normalize(providerUri) + + '/api/com.daplie.domains/accounts/' + session.token.sub + '/glue' + , session: session + }).then(function (res) { + return res.data; + }); +}; + +OAUTH3.api['glue.add'] = function (providerUri, opts) { + var session = opts.session; + var ip = opts.ip; + var tld = opts.tld; + var sld = opts.sld; + var sub = (opts.sub || '@'); + + return OAUTH3.request({ + method: 'POST' + , url: OAUTH3.url.normalize(providerUri) + + '/api/com.daplie.domains/accounts/' + session.token.sub + '/glue/' + + tld + '/' + sld + '/' + sub + , session: session + , data: { ip: ip } + }, {}).then(function (res) { + return res; + }); +}; + }('undefined' !== typeof exports ? exports : window));