Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bestbuy

Package Overview
Dependencies
Maintainers
3
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bestbuy - npm Package Compare versions

Comparing version 2.3.1 to 2.4.0

.gitignore

2

examples/near-realtime-availability.js

@@ -9,3 +9,3 @@ // Initialize with your Best Buy developer API key - if it is present as a

bby.realTimeAvailability(SKU, {postalCode: 90210}, function (err, data) {
bby.realTimeAvailability(SKU, { postalCode: 90210 }, function (err, data) {
if (err) console.error(err);

@@ -12,0 +12,0 @@ console.log(JSON.stringify(data, null, 2));

@@ -46,3 +46,4 @@ var pkg = require('./package.json');

maxRetries: 0,
retryInterval: 2000
retryInterval: 2000,
timeout: 5000
};

@@ -49,0 +50,0 @@

@@ -12,4 +12,8 @@ module.exports = apiServiceFactory;

var baseRequest = {method: 'get', headers: opts.headers};
var baseRequestParams = {format: 'json', apiKey: opts.key};
var baseRequest = {
method: 'get',
headers: opts.headers,
timeout: opts.timeout
};
var baseRequestParams = { format: 'json', apiKey: opts.key };

@@ -53,14 +57,14 @@ function apiService (requestOpts, callback, attempts) {

return getBodyFromStream(response.data)
.then(body => {
wrappingError.body = requestFormat === 'json' ? JSON.parse(body) : body;
return wrappingError;
})
.catch(error => {
wrappingError.errorHandlingError = error;
return wrappingError;
})
.then(wrappingError => {
if (callback) callback(wrappingError);
throw wrappingError;
});
.then(body => {
wrappingError.body = requestFormat === 'json' ? JSON.parse(body) : body;
return wrappingError;
})
.catch(error => {
wrappingError.errorHandlingError = error;
return wrappingError;
})
.then(wrappingError => {
if (callback) callback(wrappingError);
throw wrappingError;
});
} else {

@@ -102,3 +106,3 @@ wrappingError.body = response.data;

if (!debugInstance) {
debugInstance = axios.create({timeout: 5000});
debugInstance = axios.create();
rateLimiter.rateLimiter(debugInstance, opts.requestsPerSecond);

@@ -110,3 +114,3 @@ debugLogger(debugInstance, opts.debug);

if (!instance) {
instance = axios.create({timeout: 5000});
instance = axios.create();
rateLimiter.rateLimiter(instance, opts.requestsPerSecond);

@@ -113,0 +117,0 @@ }

@@ -61,3 +61,3 @@ module.exports = apiStreamJsonServiceFactory;

} else {
req.params = Object.assign({}, req.params, {page: header.metadata.page.current + 1});
req.params = Object.assign({}, req.params, { page: header.metadata.page.current + 1 });
streamAllData(jsonFilterKey, req, stream).catch(err => { throw err; });

@@ -69,3 +69,3 @@ }

} else {
req.params = Object.assign({}, req.params, {cursorMark: header.nextCursorMark});
req.params = Object.assign({}, req.params, { cursorMark: header.nextCursorMark });
streamAllData(jsonFilterKey, req, stream).catch(err => { throw err; });

@@ -75,6 +75,6 @@ }

})
.catch(error => {
stream.emit('error', error);
stream.end();
});
.catch(error => {
stream.emit('error', error);
stream.end();
});
}

@@ -81,0 +81,0 @@

@@ -76,3 +76,3 @@ module.exports = apiStreamXmlServiceFactory;

} else {
req.params = Object.assign({}, req.params, {cursorMark: header.nextCursorMark});
req.params = Object.assign({}, req.params, { cursorMark: header.nextCursorMark });
streamAllData(xmlFilterKey, req, stream).catch(err => { throw err; });

@@ -82,6 +82,6 @@ }

})
.catch(error => {
stream.emit('error', error);
stream.end();
});
.catch(error => {
stream.emit('error', error);
stream.end();
});
}

@@ -88,0 +88,0 @@

module.exports = availabilityEndpoint;
function availabilityEndpoint (opts) {
return {availability, availabilityAsStream};
return { availability, availabilityAsStream };

@@ -54,4 +54,4 @@ function availability (sku, storeIdsArray, params, callback) {

return {url, params};
return { url, params };
}
}
module.exports = categoriesEndpoint;
function categoriesEndpoint (opts) {
return {categories, categoriesAsStream};
return { categories, categoriesAsStream };

@@ -23,4 +23,4 @@ function categories (search, params, callback) {

return {url, params};
return { url, params };
}
}
module.exports = openBoxEndpoint;
function openBoxEndpoint (opts) {
return {openBox, openBoxAsStream};
return { openBox, openBoxAsStream };

@@ -28,3 +28,3 @@ function openBox (search, params, callback) {

} else if (typeof search === 'string' && search.length > 0) {
// Search is still a "sku", but was passed as a string
// Search is still a "sku", but was passed as a string
if (!isNaN(parseInt(search))) {

@@ -39,4 +39,4 @@ url = `${opts.url}/beta/products/${search}/openBox`;

return {url, params};
return { url, params };
}
}
module.exports = productsEndpoint;
function productsEndpoint (opts) {
return {products, productsAsStream};
return { products, productsAsStream };

@@ -35,4 +35,4 @@ function products (search, params, callback) {

return {url, params};
return { url, params };
}
}
module.exports = realTimeAvailabilityEndpoint;
function realTimeAvailabilityEndpoint (opts) {
return {realTimeAvailability};
return { realTimeAvailability };

@@ -36,4 +36,4 @@ function realTimeAvailability (sku, params, callback) {

return {url, params};
return { url, params };
}
}

@@ -38,4 +38,4 @@ module.exports = recommendationsEndpoint;

return opts.apiService({url}, callback);
return opts.apiService({ url }, callback);
};
}
module.exports = storesEndpoint;
function storesEndpoint (opts) {
return {stores, storesAsStream};
return { stores, storesAsStream };

@@ -29,4 +29,4 @@ function stores (search, params, callback) {

return {url, params};
return { url, params };
}
}

@@ -10,6 +10,6 @@ module.exports = versionEndpoint;

return opts.apiService({url}, jsonifiedCallback)
.then(version => {
return createVersionObject(version);
});
return opts.apiService({ url }, jsonifiedCallback)
.then(version => {
return createVersionObject(version);
});
};

@@ -16,0 +16,0 @@ }

@@ -7,4 +7,4 @@ module.exports = warrantiesEndpoint;

return opts.apiService({url}, callback);
return opts.apiService({ url }, callback);
};
}
{
"name": "bestbuy",
"version": "2.3.1",
"version": "2.4.0",
"description": "High level node.js client for the Best Buy API.",

@@ -44,5 +44,5 @@ "main": "index.js",

"devDependencies": {
"coveralls": "^2.11.4",
"coveralls": "^3.0.11",
"istanbul": "^0.4.0",
"semistandard": "^9.2.1",
"semistandard": "^14.2.0",
"sinon": "^8.1.1",

@@ -49,0 +49,0 @@ "tap-spec": "^4.1.1",

@@ -454,2 +454,11 @@ # Best Buy API

## Timeout
Request timeout can be configured with the `timeout` option. This value is set to 5000ms by default.
```js
var bby = require('bestbuy')({
key: 'YOURKEY',
timeout: 15000 // wait for 15 seconds before erroring due to timeout
});
```
## Tests

@@ -456,0 +465,0 @@ Run the existing tests with:

@@ -19,3 +19,3 @@ const axios = require('axios');

})
.catch(err => t.error(err));
.catch(err => t.error(err));
});

@@ -62,3 +62,3 @@

})
.catch(err => t.error(err));
.catch(err => t.error(err));
});

@@ -71,3 +71,5 @@

spy();
return Promise.reject({ response: { status: 503 } });
const error = new Error('Service Unavailable');
error.response = { status: 503 };
return Promise.reject(error);
});

@@ -74,0 +76,0 @@ const apiService = apiServiceFactory({ maxRetries: 2, retryInterval: 0 });

@@ -17,16 +17,16 @@ var test = require('./lib/tape-nock-setup');

bby.stores('area(55119,25)&storeType=Big Box')
.then(function (data) {
t.ok(data.stores.length > 0, 'has stores');
var stores = data.stores.map(function (store) {
return store.storeId;
});
return bby.availability(AVAILABLE_SKU, stores);
})
.then(function (data) {
t.ok(data.products.length > 0, 'has products');
})
.catch(function (err) {
t.error(err);
})
.then(t.end);
.then(function (data) {
t.ok(data.stores.length > 0, 'has stores');
var stores = data.stores.map(function (store) {
return store.storeId;
});
return bby.availability(AVAILABLE_SKU, stores);
})
.then(function (data) {
t.ok(data.products.length > 0, 'has products');
})
.catch(function (err) {
t.error(err);
})
.then(t.end);
});

@@ -36,17 +36,17 @@

bby.stores('area(55119,50)&storeType=Big Box')
.then(function (data) {
t.ok(data.stores.length > 0, 'has stores');
var stores = data.stores.map(function (store) {
return store.storeId;
});
return bby.availability(ANOTHER_AVAILABILE_SKU, stores, {format: 'xml'});
})
.then(function (data) {
t.ok(data.startsWith('<?xml'), 'xml string returned');
t.ok(data.indexOf('product>') > -1, 'products returned');
})
.catch(function (err) {
t.error(err);
})
.then(t.end);
.then(function (data) {
t.ok(data.stores.length > 0, 'has stores');
var stores = data.stores.map(function (store) {
return store.storeId;
});
return bby.availability(ANOTHER_AVAILABILE_SKU, stores, { format: 'xml' });
})
.then(function (data) {
t.ok(data.startsWith('<?xml'), 'xml string returned');
t.ok(data.indexOf('product>') > -1, 'products returned');
})
.catch(function (err) {
t.error(err);
})
.then(t.end);
});

@@ -76,3 +76,3 @@

});
bby.availability(AVAILABLE_SKU, stores, {show: 'all'}, function (err, data) {
bby.availability(AVAILABLE_SKU, stores, { show: 'all' }, function (err, data) {
t.error(err, 'no error');

@@ -95,7 +95,7 @@ t.equals(data.products[0].active, true, 'is active');

bby.availability(AVAILABLE_SKU, 'blah')
.catch(function (err) {
t.ok(err, 'has error');
t.equals(err.message, 'Second parameter of "availability" must be store id(s), and it must be either a number or array of numbers');
})
.then(t.end);
.catch(function (err) {
t.ok(err, 'has error');
t.equals(err.message, 'Second parameter of "availability" must be store id(s), and it must be either a number or array of numbers');
})
.then(t.end);
});

@@ -105,8 +105,8 @@

bby.availability({}, 'blah')
.then(function (data) {})
.catch(function (err) {
t.ok(err, 'has error');
t.equals(err.message, 'First parameter of "availability" must be the SKU, and it must be either a number or a string');
})
.then(t.end);
.then(function (data) {})
.catch(function (err) {
t.ok(err, 'has error');
t.equals(err.message, 'First parameter of "availability" must be the SKU, and it must be either a number or a string');
})
.then(t.end);
});

@@ -116,8 +116,8 @@

bby.availability(AVAILABLE_SKU, 123, 123, 123)
.then(function (data) {})
.catch(function (err) {
t.ok(err, 'has error');
t.equals(err.message, 'Unrecognized parameter length when calling "availability" method');
})
.then(t.end);
.then(function (data) {})
.catch(function (err) {
t.ok(err, 'has error');
t.equals(err.message, 'Unrecognized parameter length when calling "availability" method');
})
.then(t.end);
});

@@ -167,3 +167,3 @@

try {
stream = bby.availabilityAsStream(ANOTHER_AVAILABILE_SKU, stores, {format: 'xml'});
stream = bby.availabilityAsStream(ANOTHER_AVAILABILE_SKU, stores, { format: 'xml' });
} catch (err) {

@@ -170,0 +170,0 @@ console.error(err);

@@ -39,3 +39,3 @@ var test = require('./lib/tape-nock-setup');

t.throws(() => {
var BBY = BestBuy({key: false});
var BBY = BestBuy({ key: false });
BBY.products();

@@ -42,0 +42,0 @@ }, /A Best Buy developer API key is required/);

@@ -18,12 +18,12 @@ var test = require('./lib/tape-nock-setup');

})
.then(function (data) {
t.ok(data.categories.length > 0, 'categories returned');
t.false(data.categories[0].active, 'no active');
t.ok(data.categories[0].name, 'name returned');
t.ok(data.categories[0].id, 'id returned');
})
.catch(function (err) {
t.error(err);
})
.then(t.end);
.then(function (data) {
t.ok(data.categories.length > 0, 'categories returned');
t.false(data.categories[0].active, 'no active');
t.ok(data.categories[0].name, 'name returned');
t.ok(data.categories[0].id, 'id returned');
})
.catch(function (err) {
t.error(err);
})
.then(t.end);
});

@@ -37,10 +37,10 @@

})
.then(function (data) {
t.ok(data.startsWith('<?xml'), 'xml string returned');
t.ok(data.indexOf('category>') > -1, 'categories returned');
t.end();
})
.catch(function (err) {
t.error(err);
});
.then(function (data) {
t.ok(data.startsWith('<?xml'), 'xml string returned');
t.ok(data.indexOf('category>') > -1, 'categories returned');
t.end();
})
.catch(function (err) {
t.error(err);
});
});

@@ -50,3 +50,3 @@

// Product search for all items reviewed with exactly 4, show only name + sku
bby.categories('(name=Video Games)', {pageSize: 1}, function (err, data) {
bby.categories('(name=Video Games)', { pageSize: 1 }, function (err, data) {
t.error(err, 'no error');

@@ -82,3 +82,3 @@

try {
stream = bby.categoriesAsStream('name="V*"', {show: 'name'});
stream = bby.categoriesAsStream('name="V*"', { show: 'name' });
} catch (err) {

@@ -115,3 +115,3 @@ console.error(err);

try {
stream = bby.categoriesAsStream('name="V*"', {format: 'xml'});
stream = bby.categoriesAsStream('name="V*"', { format: 'xml' });
} catch (err) {

@@ -118,0 +118,0 @@ console.error(err);

@@ -18,14 +18,14 @@ var test = require('./lib/tape-nock-setup');

})
.then(function (data) {
t.ok(data.results.length > 0, 'has results');
t.ok(data.results[0].customerReviews.count, 'has count of customerReviews');
t.ok(data.results[0].customerReviews.averageScore, 'has averageScore of customerReviews');
t.ok(data.results[0].names, 'has names');
t.ok(data.results[0].offers.length > 0, 'has offers');
t.end();
})
.catch(function (err) {
t.error(err, 'no error');
t.end();
});
.then(function (data) {
t.ok(data.results.length > 0, 'has results');
t.ok(data.results[0].customerReviews.count, 'has count of customerReviews');
t.ok(data.results[0].customerReviews.averageScore, 'has averageScore of customerReviews');
t.ok(data.results[0].names, 'has names');
t.ok(data.results[0].offers.length > 0, 'has offers');
t.end();
})
.catch(function (err) {
t.error(err, 'no error');
t.end();
});
});

@@ -35,13 +35,13 @@

bby.openBox(OPEN_BOX_SKU)
.then(function (data) {
t.ok(data.results.length > 0, 'has results');
t.ok(data.results[0].customerReviews.count, 'has count of customerReviews');
t.ok(data.results[0].customerReviews.averageScore, 'has averageScore of customerReviews');
t.ok(data.results[0].names, 'has names');
t.ok(data.results[0].offers.length > 0, 'has offers');
})
.catch(function (err) {
t.error(err);
})
.then(t.end);
.then(function (data) {
t.ok(data.results.length > 0, 'has results');
t.ok(data.results[0].customerReviews.count, 'has count of customerReviews');
t.ok(data.results[0].customerReviews.averageScore, 'has averageScore of customerReviews');
t.ok(data.results[0].names, 'has names');
t.ok(data.results[0].offers.length > 0, 'has offers');
})
.catch(function (err) {
t.error(err);
})
.then(t.end);
});

@@ -51,13 +51,13 @@

bby.openBox(String(OPEN_BOX_SKU))
.then(function (data) {
t.ok(data.results.length > 0, 'has results');
t.ok(data.results[0].customerReviews.count, 'has count of customerReviews');
t.ok(data.results[0].customerReviews.averageScore, 'has averageScore of customerReviews');
t.ok(data.results[0].names, 'has names');
t.ok(data.results[0].offers.length > 0, 'has offers');
})
.catch(function (err) {
t.error(err);
})
.then(t.end);
.then(function (data) {
t.ok(data.results.length > 0, 'has results');
t.ok(data.results[0].customerReviews.count, 'has count of customerReviews');
t.ok(data.results[0].customerReviews.averageScore, 'has averageScore of customerReviews');
t.ok(data.results[0].names, 'has names');
t.ok(data.results[0].offers.length > 0, 'has offers');
})
.catch(function (err) {
t.error(err);
})
.then(t.end);
});

@@ -67,13 +67,13 @@

bby.openBox('categoryId=abcat0502000')
.then(function (data) {
t.ok(data.results.length > 0, 'has results');
t.ok(data.results[0].customerReviews.count, 'has count of customerReviews');
t.ok(data.results[0].customerReviews.averageScore, 'has averageScore of customerReviews');
t.ok(data.results[0].names, 'has names');
t.ok(data.results[0].offers.length > 0, 'has offers');
})
.catch(function (err) {
t.error(err);
})
.then(t.end);
.then(function (data) {
t.ok(data.results.length > 0, 'has results');
t.ok(data.results[0].customerReviews.count, 'has count of customerReviews');
t.ok(data.results[0].customerReviews.averageScore, 'has averageScore of customerReviews');
t.ok(data.results[0].names, 'has names');
t.ok(data.results[0].offers.length > 0, 'has offers');
})
.catch(function (err) {
t.error(err);
})
.then(t.end);
});

@@ -80,0 +80,0 @@

@@ -32,10 +32,10 @@ var test = require('./lib/tape-nock-setup');

})
.then(function (data) {
t.ok(data.products.length > 0, 'has products');
t.false(data.products[0].customerReviewCount, 'no review count');
t.false(data.products[0].customerReviewAverage, 'no review average');
t.ok(data.products[0].name, 'has name');
t.ok(data.products[0].sku, 'has sku');
})
.then(t.end);
.then(function (data) {
t.ok(data.products.length > 0, 'has products');
t.false(data.products[0].customerReviewCount, 'no review count');
t.false(data.products[0].customerReviewAverage, 'no review average');
t.ok(data.products[0].name, 'has name');
t.ok(data.products[0].sku, 'has sku');
})
.then(t.end);
});

@@ -49,7 +49,7 @@

})
.then(function (data) {
t.ok(data.startsWith('<?xml'), 'xml string returned');
t.ok(data.indexOf('product>') > -1, 'products returned');
})
.then(t.end);
.then(function (data) {
t.ok(data.startsWith('<?xml'), 'xml string returned');
t.ok(data.indexOf('product>') > -1, 'products returned');
})
.then(t.end);
});

@@ -64,11 +64,11 @@

})
.then(function (data) {
t.ok(data.products.length > 0, 'has results');
t.false(data.products[0].customerReviewCount);
t.false(data.products[0].customerReviewAverage);
t.ok(data.products[0].name, 'has name');
t.ok(data.products[0].sku, 'has sku');
t.equals(data.from, 6, 'from is equal to 6');
})
.then(t.end);
.then(function (data) {
t.ok(data.products.length > 0, 'has results');
t.false(data.products[0].customerReviewCount);
t.false(data.products[0].customerReviewAverage);
t.ok(data.products[0].name, 'has name');
t.ok(data.products[0].sku, 'has sku');
t.equals(data.from, 6, 'from is equal to 6');
})
.then(t.end);
});

@@ -81,7 +81,7 @@

})
.catch(function (error) {
t.equals(error.status, 400, 'error code 400 returned');
t.ok(error.body.error, 'error element present');
t.end();
});
.catch(function (error) {
t.equals(error.status, 400, 'error code 400 returned');
t.ok(error.body.error, 'error element present');
t.end();
});
});

@@ -92,7 +92,7 @@

bby.products('gurgleflats')
.catch(function (error) {
t.equals(error.status, 400, 'status 400 returned');
t.ok(error.body.error, 'error element present');
t.end();
});
.catch(function (error) {
t.equals(error.status, 400, 'status 400 returned');
t.ok(error.body.error, 'error element present');
t.end();
});
});

@@ -121,10 +121,10 @@

})
.then(function (data) {
t.false(data.products[0].customerReviewCount, 'no review count');
t.false(data.products[0].customerReviewAverage, 'no rewview average');
t.ok(data.products[0].name, 'has name');
t.ok(data.products[0].sku, 'has sku');
t.ok(data.products[0].salePrice, 'has salePrice');
})
.then(t.end);
.then(function (data) {
t.false(data.products[0].customerReviewCount, 'no review count');
t.false(data.products[0].customerReviewAverage, 'no rewview average');
t.ok(data.products[0].name, 'has name');
t.ok(data.products[0].sku, 'has sku');
t.ok(data.products[0].salePrice, 'has salePrice');
})
.then(t.end);
});

@@ -218,3 +218,3 @@

test('Handles garbage search with xml stream', test.opts, function (t) {
const stream = bby.productsAsStream('gurgleflats', {format: 'xml'});
const stream = bby.productsAsStream('gurgleflats', { format: 'xml' });
stream.on('error', err => {

@@ -228,3 +228,3 @@ t.equals(err.status, 400, 'returns response status');

test('Handles garbage search with json stream', test.opts, function (t) {
const stream = bby.productsAsStream('gurgleflats', {format: 'json'});
const stream = bby.productsAsStream('gurgleflats', { format: 'json' });
stream.on('error', err => {

@@ -231,0 +231,0 @@ t.equals(err.status, 400, 'returns response status');

@@ -24,13 +24,13 @@ var test = require('./lib/tape-nock-setup');

Promise.all(promises)
.then(result => {
var diff = process.hrtime(start);
var totalTime = diff[0] * NS_PER_SEC + diff[1];
.then(result => {
var diff = process.hrtime(start);
var totalTime = diff[0] * NS_PER_SEC + diff[1];
t.ok(totalTime > (promises.length - 1) * NS_PER_SEC, `took more than 2 seconds (${totalTime / NS_PER_SEC})`);
t.end();
})
.catch(error => {
t.error(error);
t.end();
});
t.ok(totalTime > (promises.length - 1) * NS_PER_SEC, `took more than 2 seconds (${totalTime / NS_PER_SEC})`);
t.end();
})
.catch(error => {
t.error(error);
t.end();
});
});

@@ -62,13 +62,13 @@

Promise.all(promises)
.then(result => {
var diff = process.hrtime(start);
var totalTime = diff[0] * NS_PER_SEC + diff[1];
.then(result => {
var diff = process.hrtime(start);
var totalTime = diff[0] * NS_PER_SEC + diff[1];
t.ok(totalTime > 1 * NS_PER_SEC, `took more than 1 second (${totalTime / NS_PER_SEC})`);
t.end();
})
.catch(error => {
t.error(error);
t.end();
});
t.ok(totalTime > 1 * NS_PER_SEC, `took more than 1 second (${totalTime / NS_PER_SEC})`);
t.end();
})
.catch(error => {
t.error(error);
t.end();
});
});

@@ -100,13 +100,13 @@

Promise.all(promises)
.then(result => {
var diff = process.hrtime(start);
var totalTime = diff[0] * NS_PER_SEC + diff[1];
.then(result => {
var diff = process.hrtime(start);
var totalTime = diff[0] * NS_PER_SEC + diff[1];
t.ok(totalTime > 1 * NS_PER_SEC, `took more than 1 second (${totalTime / NS_PER_SEC})`);
t.end();
})
.catch(error => {
t.error(error);
t.end();
});
t.ok(totalTime > 1 * NS_PER_SEC, `took more than 1 second (${totalTime / NS_PER_SEC})`);
t.end();
})
.catch(error => {
t.error(error);
t.end();
});
});

@@ -143,14 +143,14 @@

Promise.all(promises)
.then(result => {
var diff = process.hrtime(start);
var totalTime = diff[0] * NS_PER_SEC + diff[1];
.then(result => {
var diff = process.hrtime(start);
var totalTime = diff[0] * NS_PER_SEC + diff[1];
t.ok(totalTime > 1 * NS_PER_SEC, `took more than 1 second (${totalTime / NS_PER_SEC})`);
t.end();
})
.catch(error => {
console.log(error.message);
t.error(error, 'no error');
t.end();
});
t.ok(totalTime > 1 * NS_PER_SEC, `took more than 1 second (${totalTime / NS_PER_SEC})`);
t.end();
})
.catch(error => {
console.log(error.message);
t.error(error, 'no error');
t.end();
});
});

@@ -17,3 +17,3 @@ var test = require('./lib/tape-nock-setup');

test('Real time Availability check by store id using promises', test.opts, function (t) {
bby.realTimeAvailability(AVAILABLE_SKU, {storeId: RICHFIELD_STORE_ID})
bby.realTimeAvailability(AVAILABLE_SKU, { storeId: RICHFIELD_STORE_ID })
.then(function (data) {

@@ -40,3 +40,3 @@ t.ok(data.ispuEligible === true, 'Eligible for in store pickup');

test('Real time availability check by store id using callback', test.opts, function (t) {
bby.realTimeAvailability(AVAILABLE_SKU, {storeId: RICHFIELD_STORE_ID}, function (err, data) {
bby.realTimeAvailability(AVAILABLE_SKU, { storeId: RICHFIELD_STORE_ID }, function (err, data) {
t.error(err, 'no error');

@@ -59,3 +59,3 @@ t.ok(data);

test('Real time Availability check by postal code using promises', test.opts, function (t) {
bby.realTimeAvailability(AVAILABLE_SKU, {postalCode: MINNEAPOLIS_POSTAL_CODE})
bby.realTimeAvailability(AVAILABLE_SKU, { postalCode: MINNEAPOLIS_POSTAL_CODE })
.then(function (data) {

@@ -70,7 +70,7 @@ t.ok(data.ispuEligible === true, 'Eligible for in store pickup');

})
.then(t.end);
.then(t.end);
});
test('Real time availability check by postal code using callback', test.opts, function (t) {
bby.realTimeAvailability(AVAILABLE_SKU, {postalCode: MINNEAPOLIS_POSTAL_CODE}, function (err, data) {
bby.realTimeAvailability(AVAILABLE_SKU, { postalCode: MINNEAPOLIS_POSTAL_CODE }, function (err, data) {
t.error(err, 'no error');

@@ -86,3 +86,3 @@ t.ok(data.ispuEligible === true, 'Eligible for in store pickup');

test('Real time availability search invalid sku error using callback', test.opts, function (t) {
bby.realTimeAvailability({}, {storeId: RICHFIELD_STORE_ID}, function (err, data) {
bby.realTimeAvailability({}, { storeId: RICHFIELD_STORE_ID }, function (err, data) {
t.equals(err.message, 'First parameter of "realTimeAvailability" must be the SKU, and it must be either a number or a string');

@@ -94,3 +94,3 @@ t.end();

test('Real time availability search invalid sku error using promises', test.opts, function (t) {
bby.realTimeAvailability({}, {storeId: RICHFIELD_STORE_ID})
bby.realTimeAvailability({}, { storeId: RICHFIELD_STORE_ID })
.catch(function (err) {

@@ -104,3 +104,3 @@ t.ok(err, 'has error');

test('Real time availability search unavailable sku using callback', test.opts, function (t) {
bby.realTimeAvailability(UNAVAILABLE_SKU, {storeId: RICHFIELD_STORE_ID}, function (err, data) {
bby.realTimeAvailability(UNAVAILABLE_SKU, { storeId: RICHFIELD_STORE_ID }, function (err, data) {
t.error(err, 'no error');

@@ -115,3 +115,3 @@ t.ok(data);

test('Real time availability search unavailable sku using promises', test.opts, function (t) {
bby.realTimeAvailability(UNAVAILABLE_SKU, {storeId: RICHFIELD_STORE_ID})
bby.realTimeAvailability(UNAVAILABLE_SKU, { storeId: RICHFIELD_STORE_ID })
.then(function (data) {

@@ -124,3 +124,3 @@ t.ok(data.ispuEligible === false, 'Eligible for in store pickup');

})
.then(t.end);
.then(t.end);
});

@@ -127,0 +127,0 @@

@@ -49,3 +49,3 @@ var test = require('./lib/tape-nock-setup');

test('Recommendations search - trendingview - criteria as object', test.opts, function (t) {
bby.recommendations('trendingViewed', {categoryId: 'abcat0502000'})
bby.recommendations('trendingViewed', { categoryId: 'abcat0502000' })
.then(function (data) {

@@ -52,0 +52,0 @@ t.ok(data.results.length > 0, 'results returned');

@@ -42,3 +42,3 @@ var test = require('./lib/tape-nock-setup');

// Do a query for stores
bby.stores('area(55119,25)&storeType=Big Box', {format: 'xml'})
bby.stores('area(55119,25)&storeType=Big Box', { format: 'xml' })
.then(function (data) {

@@ -66,3 +66,3 @@ t.ok(data.startsWith('<?xml'), 'xml string returned');

var bby = BBY(opts);
bby.stores(1443, {format: 'xml'})
bby.stores(1443, { format: 'xml' })
.then(function (data) {

@@ -106,3 +106,3 @@ t.ok(data.startsWith('<?xml'), 'xml string returned');

// Do a query for stores
var stream = bby.storesAsStream('area(55119,25)&storeType=Big Box', {format: 'xml'});
var stream = bby.storesAsStream('area(55119,25)&storeType=Big Box', { format: 'xml' });

@@ -109,0 +109,0 @@ var cnt = 0;

@@ -6,3 +6,3 @@ var test = require('tape');

var bby = BBY({key: 'XXX'});
var bby = BBY({ key: 'XXX' });

@@ -9,0 +9,0 @@ test('User-Agent matches package version', function (t) {

@@ -14,11 +14,11 @@ var test = require('./lib/tape-nock-setup');

bby.version()
.then(function (data) {
t.ok(data.packageVersion, 'package version returned');
t.ok(data.apiVersion, 'API version returned');
t.end();
})
.catch(err => {
t.error(err, 'no error');
t.end();
});
.then(function (data) {
t.ok(data.packageVersion, 'package version returned');
t.ok(data.apiVersion, 'API version returned');
t.end();
})
.catch(err => {
t.error(err, 'no error');
t.end();
});
});

@@ -25,0 +25,0 @@

@@ -15,6 +15,6 @@ var test = require('./lib/tape-nock-setup');

bby.warranties(6354884)
.then(function (data) {
t.ok(data.length > 0, 'warranties returned');
t.end();
});
.then(function (data) {
t.ok(data.length > 0, 'warranties returned');
t.end();
});
});

@@ -21,0 +21,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc