From a0a3d06129f5f1d2a88ddab48061625467ab743d Mon Sep 17 00:00:00 2001 From: Daniel Wygonski Date: Tue, 6 Apr 2021 17:03:37 +0200 Subject: [PATCH] changed appId to app_id --- lib/api.js | 89 ++++++++++++++++++++---------------------------------- 1 file changed, 33 insertions(+), 56 deletions(-) diff --git a/lib/api.js b/lib/api.js index b407369..4c18d7d 100644 --- a/lib/api.js +++ b/lib/api.js @@ -1,4 +1,4 @@ -const request = require('request'); +const request = require('request') const totp = require('notp').totp; const base32 = require('thirty-two'); @@ -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', { app_id: 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, app_id: 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', { app_id: 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', { app_id: 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, app_id: 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, app_id: 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, app_id: 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, app_id: 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,63 +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, app_id: appId ? appId : this.appId }, body => body.data); } - delistItem(item_ids) { - return this.makeRequest('delist_item', { item_ids }, body => body.data); - } - - relistItem(item_ids, prices) { - - if (arguments.length === 1) { - const entries = Object.entries(item_ids); - item_ids = entries.map(pair => pair[0]); - prices = entries.map(pair => pair[1]); - } - - item_ids = item_ids.join(','); - prices = prices.join(','); - - return this.makeRequest('relist_item', {item_ids, prices}, 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, app_id: 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, app_id: 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, app_id: 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, app_id: 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, app_id: 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); } - getRecentTradeOffers(active_only = true) { - return this.makeRequest('get_recent_trade_offers', { active_only }, 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, app_id: 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, app_id: appId ? appId : this.appId }, body => body.data); } makeRequest(endpoint, params = {}, manipulator) { @@ -167,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) => { @@ -193,4 +170,4 @@ class Bitskins { } } -module.exports = Bitskins; \ No newline at end of file +module.exports = Bitskins;