Skip to content
This repository has been archived by the owner on Feb 10, 2021. It is now read-only.

Commit

Permalink
Fixed linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
avbel committed Oct 31, 2017
1 parent d8019df commit cef578b
Show file tree
Hide file tree
Showing 4 changed files with 347 additions and 322 deletions.
2 changes: 1 addition & 1 deletion lib/index.js
Expand Up @@ -46,7 +46,7 @@ var CatapultClient = function (config) {
this.AvailableNumber = new AvailableNumber(client);
this.PhoneNumber = new PhoneNumber(client);
this.v2 = {
Message: new MessageV2(client)
Message : new MessageV2(client)
};
};

Expand Down
40 changes: 20 additions & 20 deletions lib/v2/message.js
Expand Up @@ -61,7 +61,7 @@ function findFirstDescendant(obj, name){
* @param {Object} client Catapult client
*/
var Message = function (client) {
this.__createIrisRequestOptions = function (params) {
this._createIrisRequestOptions = function (params) {
var auth = params.auth;
var baseUrl = "https://dashboard.bandwidth.com/v1.0";
var accountPath = "/api/accounts/" + auth.accountId;
Expand Down Expand Up @@ -89,7 +89,7 @@ var Message = function (client) {
};
};

this.__handleResponse = function (response) {
this._handleResponse = function (response) {
var body = convert.xml2js(response.body || "<Response></Response>", {compact: true, nativeType: true});
var code = findFirstDescendant(body, "ErrorCode");
var description = findFirstDescendant(body, "Description");
Expand Down Expand Up @@ -121,12 +121,12 @@ var Message = function (client) {
return [body, response];
};

this.__makeIrisRequest = function (params) {
return request(this.__createIrisRequestOptions(params)).then(this.__handleResponse.bind(this));
this._makeIrisRequest = function (params) {
return request(this._createIrisRequestOptions(params)).then(this._handleResponse.bind(this));
};

this.__createApplication = function (auth, data) {
return this.__makeIrisRequest({
this._createApplication = function (auth, data) {
return this._makeIrisRequest({
path : "applications",
method : "POST",
auth : auth,
Expand All @@ -145,8 +145,8 @@ var Message = function (client) {
});
};

this.__createLocation = function (auth, data) {
return this.__makeIrisRequest({
this._createLocation = function (auth, data) {
return this._makeIrisRequest({
path : "sites/" + auth.subaccountId + "/sippeers",
method : "POST",
auth : auth,
Expand All @@ -163,11 +163,11 @@ var Message = function (client) {
});
};

this.__enableSms = function (auth, options, application) {
this._enableSms = function (auth, options, application) {
if (!options || !options.enabled) {
return Promise.resolve();
}
return this.__makeIrisRequest({
return this._makeIrisRequest({
path : "sites/" + auth.subaccountId + "/sippeers/" + application.locationId + "/products/messaging/features/sms",
method : "POST",
auth : auth,
Expand All @@ -191,11 +191,11 @@ var Message = function (client) {
});
};

this.__enableMms = function (auth, options, application) {
this._enableMms = function (auth, options, application) {
if (!options || !options.enabled) {
return Promise.resolve();
}
return this.__makeIrisRequest({
return this._makeIrisRequest({
path : "sites/" + auth.subaccountId + "/sippeers/" + application.locationId + "/products/messaging/features/mms",
method : "POST",
auth : auth,
Expand All @@ -216,8 +216,8 @@ var Message = function (client) {
});
};

this.__assignApplicationToLocation = function (auth, application) {
return this.__makeIrisRequest({
this._assignApplicationToLocation = function (auth, application) {
return this._makeIrisRequest({
path : "sites/" + auth.subaccountId + "/sippeers/" + application.locationId + "/products/messaging/applicationSettings",
method : "POST",
auth : auth,
Expand Down Expand Up @@ -258,19 +258,19 @@ var Message = function (client) {
this.createMessagingApplication = function (auth, data, callback) {
var app;
var self = this;
return Promise.all([self.__createApplication(auth, data), self.__createLocation(auth, data)])
return Promise.all([self._createApplication(auth, data), self._createLocation(auth, data)])
.then(function (result) {
app = {
applicationId: result[0],
locationId: result[1]
};
return self.__enableSms(auth, data.smsOptions, app);
return self._enableSms(auth, data.smsOptions, app);
})
.then(function () {
return self.__enableMms(auth, data.mmsOptions, app);
return self._enableMms(auth, data.mmsOptions, app);
})
.then(function () {
return self.__assignApplicationToLocation(auth, app);
return self._assignApplicationToLocation(auth, app);
})
.then(function () {
return app;
Expand All @@ -295,7 +295,7 @@ var Message = function (client) {
var queryXml = util.isFunction(query.toXml) ? query.toXml() : query;
queryXml["SiteId"] = {_text: auth.subaccountId};
queryXml["PeerId"] = {_text: app.locationId};
return self.__makeIrisRequest({
return self._makeIrisRequest({
path : "orders",
method : "POST",
auth : auth,
Expand All @@ -320,7 +320,7 @@ var Message = function (client) {
timeoutReached = true;
}, timeout);
timer = setInterval(function () {
return self.__makeIrisRequest({
return self._makeIrisRequest({
path : "orders/" + orderId,
method : "GET",
auth : auth
Expand Down

0 comments on commit cef578b

Please sign in to comment.