2017-03-15 09:38:18 +00:00
|
|
|
;(function (exports) {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var OAUTH3 = exports.OAUTH3 = exports.OAUTH3 || require('./oauth3.core.js').OAUTH3;
|
|
|
|
|
|
|
|
OAUTH3.api['dns.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 + '/dns'
|
|
|
|
, session: session
|
|
|
|
}).then(function (res) {
|
|
|
|
return res.data.records || res.data;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2017-03-16 05:48:39 +00:00
|
|
|
OAUTH3.api['devices.list'] = function (providerUri, opts) {
|
|
|
|
var session = opts.session;
|
|
|
|
|
|
|
|
return OAUTH3.request({
|
|
|
|
url: OAUTH3.url.normalize(providerUri)
|
|
|
|
+ '/api/com.daplie.domains/accounts/' + session.token.sub + '/devices'
|
|
|
|
, method: 'GET'
|
|
|
|
, session: session
|
|
|
|
}, {}).then(function (res) {
|
|
|
|
return res.data.devices || res.data;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2017-03-17 20:17:37 +00:00
|
|
|
OAUTH3.api['devices.attach'] = function (providerUri, opts) {
|
|
|
|
var session = opts.session;
|
|
|
|
|
|
|
|
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: 'POST'
|
|
|
|
, 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/' + 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;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2017-03-16 05:48:39 +00:00
|
|
|
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 || '')
|
|
|
|
, method: 'DELETE'
|
|
|
|
, session: session
|
|
|
|
}, {}).then(function (res) {
|
|
|
|
return res.data.device || res.data;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2017-03-15 09:38:18 +00:00
|
|
|
}('undefined' !== typeof exports ? exports : window));
|