Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eslint fixes #79

Merged
merged 2 commits into from
Mar 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/buildURL.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
'use strict';

/**
* This method is used to build the url based on
* the type of request.
*/

const buildURL = {

/**
* Builds the findings(search) URL.
*
Expand Down
14 changes: 6 additions & 8 deletions src/findingApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ const findItemsByKeywords = function (options) {
const url = urlObject.buildSearchUrl(this.options);
return getRequest(url).then((data) => {
return JSON.parse(data).findItemsByKeywordsResponse;

}, console.error
}, console.error // eslint-disable-line no-console
);
};

Expand All @@ -33,8 +32,7 @@ const findItemsByCategory = function (categoryID) {
const url = urlObject.buildSearchUrl(this.options);
return getRequest(url).then((data) => {
return JSON.parse(data).findItemsByCategoryResponse;

}, console.error
}, console.error // eslint-disable-line no-console
);
};

Expand All @@ -55,7 +53,7 @@ const findCompletedItems = function (options) {
return getRequest(url).then((data) => {
return JSON.parse(data).findCompletedItemsResponse;

}, console.error
}, console.error // eslint-disable-line no-console
);
};

Expand All @@ -75,7 +73,7 @@ const findItemsAdvanced = function (options) {
const url = urlObject.buildSearchUrl(this.options);
return getRequest(url).then((data) => {
return JSON.parse(data).findItemsAdvancedResponse;
}, console.error
}, console.error // eslint-disable-line no-console
);
};

Expand All @@ -85,7 +83,7 @@ const getVersion = function () {
const url = urlObject.buildSearchUrl(this.options);
return getRequest(url).then((data) => {
return JSON.parse(data).getVersionResponse[0];
}, console.error
}, console.error // eslint-disable-line no-console
);
};

Expand All @@ -104,7 +102,7 @@ const findItemsByProduct = function (options) {
return getRequest(url).then((data) => {
return JSON.parse(data).findItemsByProductResponse;

}, console.error
}, console.error // eslint-disable-line no-console
);
};

Expand Down
5 changes: 2 additions & 3 deletions src/merchandising.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const getMostWatchedItems = function (merchOptions) {
return getRequest(`http://${this.options.baseSvcUrl}/${MERCH_SRVC_NAME}?OPERATION-NAME=getMostWatchedItems&SERVICE-NAME=${MERCH_SRVC_NAME}&SERVICE-VERSION=1.1.0&CONSUMER-ID=${this.options.clientID}&RESPONSE-DATA-FORMAT=JSON&REST-PAYLOAD${url}`).then((result) => {
return JSON.parse(result);
}).catch((error) => {
console.log(error);
console.log(error); // eslint-disable-line no-console
});
};

Expand All @@ -30,11 +30,10 @@ const getMostWatchedItems = function (merchOptions) {
const getSimilarItems = function (merchOptions) {
if (!this.options.clientID) throw new Error('Missing App id or client id');
const url = parseObj(merchOptions);
console.log(`http://${this.options.baseSvcUrl}/${MERCH_SRVC_NAME}?OPERATION-NAME=getSimilarItems&SERVICE-NAME=${MERCH_SRVC_NAME}&SERVICE-VERSION=1.1.0&CONSUMER-ID=${this.options.clientID}&RESPONSE-DATA-FORMAT=JSON&REST-PAYLOAD${url}`);
return getRequest(`http://${this.options.baseSvcUrl}/${MERCH_SRVC_NAME}?OPERATION-NAME=getSimilarItems&SERVICE-NAME=${MERCH_SRVC_NAME}&SERVICE-VERSION=1.1.0&CONSUMER-ID=${this.options.clientID}&RESPONSE-DATA-FORMAT=JSON&REST-PAYLOAD${url}`).then((result) => {
return JSON.parse(result);
}).catch((error) => {
console.log(error);
console.log(error); // eslint-disable-line no-console
});
};

Expand Down
8 changes: 4 additions & 4 deletions src/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const qs = require('querystring');

const getRequest = (url) => {
if (url.includes('http://')) httpRequest = require('http');
return new Promise(function (resolve, reject) {
return new Promise(((resolve, reject) => {
httpRequest.get(url, res => {
res.setEncoding('utf8');
let body = '';
Expand All @@ -22,7 +22,7 @@ const getRequest = (url) => {

});
});
});
}));
};

const makeRequest = function postRequest(self, endpoint, methodName, token) {
Expand All @@ -44,7 +44,7 @@ const makeRequest = function postRequest(self, endpoint, methodName, token) {
...self.headers
}
};
return new Promise(function (resolve, reject) {
return new Promise(((resolve, reject) => {
const req = httpRequest.request(options, res => {
res.setEncoding('utf8');
let body = '';
Expand All @@ -64,7 +64,7 @@ const makeRequest = function postRequest(self, endpoint, methodName, token) {
//console.log('request ' + dataString);
if (methodName === 'POST') req.write(dataString);
req.end();
});
}));
};


Expand Down
8 changes: 4 additions & 4 deletions src/shopping.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const getAllCategories = function (categoryID) {
const url = urlObject.buildShoppingUrl(this.options);
return getRequest(url).then((data) => {
return JSON.parse(data);
}, console.error
}, console.error // eslint-disable-line no-console
);
};

Expand All @@ -25,7 +25,7 @@ const getUserDetails = function (input) {
const url = urlObject.buildShoppingUrl(this.options);
return getRequest(url).then((data) => {
return JSON.parse(data);
}, console.error
}, console.error // eslint-disable-line no-console
);
};

Expand All @@ -37,7 +37,7 @@ const getItemStatus = function (itemIds) {
const url = urlObject.buildShoppingUrl(this.options);
return getRequest(url).then((data) => {
return JSON.parse(data);
}, console.error
}, console.error // eslint-disable-line no-console
);
};

Expand All @@ -54,7 +54,7 @@ const getShippingCosts = function (input) {
url = url + params;
return getRequest(url).then((data) => {
return JSON.parse(data);
}, console.error
}, console.error // eslint-disable-line no-console
);
};

Expand Down