Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Commit

Permalink
Remove config from SDK
Browse files Browse the repository at this point in the history
Global config now needs to be passed into the SDK at runtime.

Signed-off-by: Scott Ware <[email protected]>
  • Loading branch information
srware committed May 18, 2018
1 parent d7d20f1 commit aa6a905
Show file tree
Hide file tree
Showing 49 changed files with 1,989 additions and 2,239 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ node_modules
*/coverage/*
*/dist/*
*~
global.json
1 change: 0 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
buildscripts/
test/
Gruntfile.js
config/global.json
10 changes: 7 additions & 3 deletions api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

"use strict";
module.exports = {
rest: require('./rest'),
ws: require('./ws')
module.exports = function(config) {
var module = {};

module.rest = require('./rest')(config);
module.ws = require('./ws');

return module;
};
206 changes: 103 additions & 103 deletions api/rest/accounts.def.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,107 +24,107 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

"use strict";

var common = require('../../lib/common');
var api = require('./api');
var ConnectionOptions = require('./iot.connection.def');

//variable to be returned
var IoTKiT = {};

function CreateAccountOption(data) {
this.pathname = common.buildPath(api.accounts.CREATE);
this.token = data.userToken;
ConnectionOptions.call(this);
this.method = 'POST';
this.body = JSON.stringify(data.body);
module.exports = function(config) {
var common = require('../../lib/common');
var api = require('./api');
var ConnectionOptions = require('./iot.connection.def')(config);

var module = {};

function CreateAccountOption(data) {
this.pathname = common.buildPath(api.accounts.CREATE);
this.token = data.userToken;
ConnectionOptions.call(this);
this.method = 'POST';
this.body = JSON.stringify(data.body);
}
CreateAccountOption.prototype = new ConnectionOptions();
CreateAccountOption.prototype.constructor = CreateAccountOption;
module.CreateAccountOption = CreateAccountOption;


function GetAccountInfoOption(data) {
this.pathname = common.buildPath(api.accounts.ACCOUNT_ID, data.accountId);
this.token = data.userToken;
ConnectionOptions.call(this);
this.method = 'GET';
this.body = null;
}
GetAccountInfoOption.prototype = new ConnectionOptions();
GetAccountInfoOption.prototype.constructor = GetAccountInfoOption;
module.GetAccountInfoOption = GetAccountInfoOption;


function UpdateAccountOption(data) {
this.pathname = common.buildPath(api.accounts.ACCOUNT_ID, data.accountId);
this.token = data.userToken;
ConnectionOptions.call(this);
this.method = 'PUT';
this.body = JSON.stringify(data.body);
}
UpdateAccountOption.prototype = new ConnectionOptions();
UpdateAccountOption.prototype.constructor = UpdateAccountOption;
module.UpdateAccountOption = UpdateAccountOption;


function DeleteAccountOption(data) {
this.pathname = common.buildPath(api.accounts.ACCOUNT_ID, data.accountId);
this.token = data.userToken;
ConnectionOptions.call(this);
this.method = 'DELETE';
this.body = null;
}
DeleteAccountOption.prototype = new ConnectionOptions();
DeleteAccountOption.prototype.constructor = DeleteAccountOption;
module.DeleteAccountOption = DeleteAccountOption;


function GetAccountActivationCodeOption(data) {
this.pathname = common.buildPath(api.accounts.ACTIVATION_CODE, data.accountId);
this.token = data.userToken;
ConnectionOptions.call(this);
this.method = 'GET';
this.body = null;
}
GetAccountActivationCodeOption.prototype = new ConnectionOptions();
GetAccountActivationCodeOption.prototype.constructor = GetAccountActivationCodeOption;
module.GetAccountActivationCodeOption = GetAccountActivationCodeOption;


function RefreshAccountActivationCodeOption(data) {
this.pathname = common.buildPath(api.accounts.REFRESH, data.accountId);
this.token = data.userToken;
ConnectionOptions.call(this);
this.method = 'PUT';
this.body = null;
}
RefreshAccountActivationCodeOption.prototype = new ConnectionOptions();
RefreshAccountActivationCodeOption.prototype.constructor = RefreshAccountActivationCodeOption;
module.RefreshAccountActivationCodeOption = RefreshAccountActivationCodeOption;


function ChangeAccountUserOption(data) {
this.pathname = common.buildPath(api.accounts.USER_ID, [data.accountId, data.userId]);
this.token = data.userToken;
ConnectionOptions.call(this);
this.method = 'PUT';
this.body = JSON.stringify(data.body);
}
ChangeAccountUserOption.prototype = new ConnectionOptions();
ChangeAccountUserOption.prototype.constructor = ChangeAccountUserOption;
module.ChangeAccountUserOption = ChangeAccountUserOption;


function GetAccountUsersOption(data) {
this.pathname = common.buildPath(api.accounts.USERS, data.accountId);
this.token = data.userToken;
ConnectionOptions.call(this);
this.method = 'GET';
this.body = null;
}
GetAccountUsersOption.prototype = new ConnectionOptions();
GetAccountUsersOption.prototype.constructor = GetAccountUsersOption;
module.GetAccountUsersOption = GetAccountUsersOption;

return module;
}
CreateAccountOption.prototype = new ConnectionOptions();
CreateAccountOption.prototype.constructor = CreateAccountOption;
IoTKiT.CreateAccountOption = CreateAccountOption;


function GetAccountInfoOption(data) {
this.pathname = common.buildPath(api.accounts.ACCOUNT_ID, data.accountId);
this.token = data.userToken;
ConnectionOptions.call(this);
this.method = 'GET';
this.body = null;
}
GetAccountInfoOption.prototype = new ConnectionOptions();
GetAccountInfoOption.prototype.constructor = GetAccountInfoOption;
IoTKiT.GetAccountInfoOption = GetAccountInfoOption;


function UpdateAccountOption(data) {
this.pathname = common.buildPath(api.accounts.ACCOUNT_ID, data.accountId);
this.token = data.userToken;
ConnectionOptions.call(this);
this.method = 'PUT';
this.body = JSON.stringify(data.body);
}
UpdateAccountOption.prototype = new ConnectionOptions();
UpdateAccountOption.prototype.constructor = UpdateAccountOption;
IoTKiT.UpdateAccountOption = UpdateAccountOption;


function DeleteAccountOption(data) {
this.pathname = common.buildPath(api.accounts.ACCOUNT_ID, data.accountId);
this.token = data.userToken;
ConnectionOptions.call(this);
this.method = 'DELETE';
this.body = null;
}
DeleteAccountOption.prototype = new ConnectionOptions();
DeleteAccountOption.prototype.constructor = DeleteAccountOption;
IoTKiT.DeleteAccountOption = DeleteAccountOption;


function GetAccountActivationCodeOption(data) {
this.pathname = common.buildPath(api.accounts.ACTIVATION_CODE, data.accountId);
this.token = data.userToken;
ConnectionOptions.call(this);
this.method = 'GET';
this.body = null;
}
GetAccountActivationCodeOption.prototype = new ConnectionOptions();
GetAccountActivationCodeOption.prototype.constructor = GetAccountActivationCodeOption;
IoTKiT.GetAccountActivationCodeOption = GetAccountActivationCodeOption;


function RefreshAccountActivationCodeOption(data) {
this.pathname = common.buildPath(api.accounts.REFRESH, data.accountId);
this.token = data.userToken;
ConnectionOptions.call(this);
this.method = 'PUT';
this.body = null;
}
RefreshAccountActivationCodeOption.prototype = new ConnectionOptions();
RefreshAccountActivationCodeOption.prototype.constructor = RefreshAccountActivationCodeOption;
IoTKiT.RefreshAccountActivationCodeOption = RefreshAccountActivationCodeOption;


function ChangeAccountUserOption(data) {
this.pathname = common.buildPath(api.accounts.USER_ID, [data.accountId, data.userId]);
this.token = data.userToken;
ConnectionOptions.call(this);
this.method = 'PUT';
this.body = JSON.stringify(data.body);
}
ChangeAccountUserOption.prototype = new ConnectionOptions();
ChangeAccountUserOption.prototype.constructor = ChangeAccountUserOption;
IoTKiT.ChangeAccountUserOption = ChangeAccountUserOption;


function GetAccountUsersOption(data) {
this.pathname = common.buildPath(api.accounts.USERS, data.accountId);
this.token = data.userToken;
ConnectionOptions.call(this);
this.method = 'GET';
this.body = null;
}
GetAccountUsersOption.prototype = new ConnectionOptions();
GetAccountUsersOption.prototype.constructor = GetAccountUsersOption;
IoTKiT.GetAccountUsersOption = GetAccountUsersOption;


module.exports = IoTKiT;
31 changes: 13 additions & 18 deletions api/rest/admin.def.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,17 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

"use strict";

var auth = require('./auth.def');
var users = require('./users.def');
var accounts = require('./accounts.def');
var data = require('./data.def');
var devices = require('./devices.def');
var rules = require('./rules.def');
var control = require('./control.def');
var alerts = require('./alerts.def');
module.exports = function(config) {
var module = {};

module.exports = {
auth: auth,
users: users,
accounts: accounts,
data: data,
devices: devices,
rules: rules,
control: control,
alerts: alerts
};
module.auth = require('./auth.def')(config);
module.users = require('./users.def')(config);
module.accounts = require('./accounts.def')(config);
module.data = require('./data.def')(config);
module.devices = require('./devices.def')(config);
module.rules = require('./rules.def')(config);
module.control = require('./control.def')(config);
module.alerts = require('./alerts.def')(config);

return module;
}
Loading

0 comments on commit aa6a905

Please sign in to comment.