From 41d46f8a87cd17f0c7de1c10c49aa724d5c923fb Mon Sep 17 00:00:00 2001 From: Emad-salah Date: Mon, 2 Jul 2018 13:47:24 +0100 Subject: [PATCH 1/2] Added app id option to all supported calls --- lib/api.js | 62 +++++++++++++++++++++++++++--------------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/lib/api.js b/lib/api.js index 8bb215f..e24358a 100644 --- a/lib/api.js +++ b/lib/api.js @@ -18,13 +18,13 @@ class Bitskins { return this.makeRequest('get_account_balance', body => body.data); } - getAllItemPrices(simple) { + getAllItemPrices(simple, appId) { function arrayToObject(object, item) { object[item.market_hash_name] = item.price; return object; } - return this.makeRequest('get_all_item_prices', (body) => { + return this.makeRequest('get_all_item_prices', { appId: appId ? appId : this.appId }, (body) => { if (simple) { body.prices = body.prices.reduce(arrayToObject, {}); } @@ -33,24 +33,24 @@ class Bitskins { }); } - getMarketData(names) { - return this.makeRequest('get_price_data_for_items_on_sale', { names }, body => body.data.items); + getMarketData(names, appId) { + return this.makeRequest('get_price_data_for_items_on_sale', { names, appId: appId ? appId : this.appId }, body => body.data.items); } - getAccountInventory(page) { - return this.makeRequest('get_my_inventory', body => body.data); + getAccountInventory(page, appId) { + return this.makeRequest('get_my_inventory', { appId: appId ? appId : this.appId }, body => body.data); } - getInventoryOnSale(options) { - return this.makeRequest('get_inventory_on_sale', options, body => body.data); + getInventoryOnSale(options, appId) { + return this.makeRequest('get_inventory_on_sale', { appId: appId ? appId : this.appId }, options, body => body.data); } getSpecificItemsOnSale(item_ids) { - return this.makeRequest('get_specific_items_on_sale', { item_ids }, body => body); + return this.makeRequest('get_specific_items_on_sale', { item_ids, appId: appId ? appId : this.appId }, body => body); } getResetPriceItems(page) { - return this.makeRequest('get_reset_price_items', { page }, body => body.data); + return this.makeRequest('get_reset_price_items', { page, appId: appId ? appId : this.appId }, body => body.data); } getMoneyEvents(page) { @@ -61,7 +61,7 @@ class Bitskins { return this.makeRequest('request_withdrawal', { amount, withdrawal_method }, body => body.data); } - buyItem(item_ids, prices) { + buyItem(item_ids, prices, appId) { // if just one argument, allow { itemID: price } if (arguments.length === 1) { const entries = Object.entries(item_ids); @@ -72,10 +72,10 @@ class Bitskins { item_ids = item_ids.join(','); prices = prices.join(','); - return this.makeRequest('buy_item', { item_ids, prices }, body => body.data); + return this.makeRequest('buy_item', { item_ids, prices, appId: appId ? appId : this.appId }, body => body.data); } - sellItem(item_ids, prices) { + sellItem(item_ids, prices, appId) { // if just one argument, allow { itemID: price } if (arguments.length === 1) { const entries = Object.entries(item_ids); @@ -86,10 +86,10 @@ class Bitskins { item_ids = item_ids.join(','); prices = prices.join(','); - return this.makeRequest('list_item_for_sale', { item_ids, prices }, body => body.data); + return this.makeRequest('list_item_for_sale', { item_ids, prices, appId: appId ? appId : this.appId }, body => body.data); } - modifySale(item_ids, prices) { + modifySale(item_ids, prices, appId) { // if just one argument, allow { itemID: price } if (arguments.length === 1) { const entries = Object.entries(item_ids); @@ -100,41 +100,41 @@ class Bitskins { item_ids = item_ids.join(','); prices = prices.join(','); - return this.makeRequest('modify_sale_item', { item_ids, prices }, body => body.data); + return this.makeRequest('modify_sale_item', { item_ids, prices, appId: appId ? appId : this.appId }, body => body.data); } - withdrawItem(item_ids) { + withdrawItem(item_ids, appId) { item_ids = item_ids.join(','); - return this.makeRequest('withdraw_item', { item_ids }, body => body.data); + return this.makeRequest('withdraw_item', { item_ids, appId: appId ? appId : this.appId }, body => body.data); } - bumpItem(item_ids) { + bumpItem(item_ids, appId) { item_ids = item_ids.join(','); - return this.makeRequest('bump_item', { item_ids }, body => body.data); + return this.makeRequest('bump_item', { item_ids, appId: appId ? appId : this.appId }, body => body.data); } - getBuyHistory(page) { - return this.makeRequest('get_buy_history', { page }, body => body.data); + getBuyHistory(page, appId) { + return this.makeRequest('get_buy_history', { page, appId: appId ? appId : this.appId }, body => body.data); } - getSellHistory(page) { - return this.makeRequest('get_sell_history', { page }, body => body.data); + getSellHistory(page, appId) { + return this.makeRequest('get_sell_history', { page, appId: appId ? appId : this.appId }, body => body.data); } - getItemHistory(page, names, delimiter) { - return this.makeRequest('get_item_history', { page, names, delimiter }, body => body.data); + getItemHistory(page, names, delimiter, appId) { + return this.makeRequest('get_item_history', { page, names, delimiter, appId: appId ? appId : this.appId }, body => body.data); } getTradeDetails(trade_token, trade_id) { return this.makeRequest('get_trade_details', { trade_token, trade_id }, body => body.data); } - getRecentSaleInfo(market_hash_name, page) { - return this.makeRequest('get_sales_info', { market_hash_name, page }, body => body.data); + getRecentSaleInfo(market_hash_name, page, appId) { + return this.makeRequest('get_sales_info', { market_hash_name, page, appId: appId ? appId : this.appId }, body => body.data); } - getRawPriceData(market_hash_name) { - return this.makeRequest('get_steam_price_data', { market_hash_name }, body => body.data); + getRawPriceData(market_hash_name, appId) { + return this.makeRequest('get_steam_price_data', { market_hash_name, appId: appId ? appId : this.appId }, body => body.data); } makeRequest(endpoint, params = {}, manipulator) { @@ -171,4 +171,4 @@ class Bitskins { } } -module.exports = Bitskins; \ No newline at end of file +module.exports = Bitskins; From 91f04efe1fb34a633b20ac0623f26110b3d87b82 Mon Sep 17 00:00:00 2001 From: Emad-salah Date: Mon, 2 Jul 2018 14:02:29 +0100 Subject: [PATCH 2/2] Fixed issue where appid doesn't get applies --- lib/api.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/api.js b/lib/api.js index e24358a..6b9e92c 100644 --- a/lib/api.js +++ b/lib/api.js @@ -145,8 +145,7 @@ class Bitskins { const query = Object.assign(params, { api_key: this.apiKey, - code: this.getCode(), - app_id: this.appId + code: this.getCode() }); return new Promise((resolve, reject) => {