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

app_id support #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ $ npm install bitskins-api
## Example
```js
const BitSkins = require('bitskins-api');
const bitskins = new BitSkins(apiKey, secret);
const bitskins = new BitSkins(apiKey, secret, appId);

bitskins.getTradeDetails({ trade_token: 'd3bedb77f7430e68', trade_id: 'ddc126dc3cc4e8a2' });
bitskins.getMarketData({ names: ['AK-47 | Redline (Field-Tested)'] });
Expand All @@ -23,10 +23,11 @@ bitskins.getMarketData({ names: ['AK-47 | Redline (Field-Tested)'] });

All of the following methods return a native [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise). Some methods allow you to pass addtional data via an object when calling the API. See the methods [API reference](https://bitskins.com/api) to see what data can be sent.

### Constructor(apiKey, secret)
### Constructor(apiKey, secret, appId)

- `apiKey` - Your BitSkins API key. Can be found in your [settings page](https://bitskins.com/settings)
- `secret` - Your 2FA secret. This is shown to you when enabling 2FA on your account.
- `appId` - The Steam appId for the inventory's game (defaults to CS:GO if not specified). (optional)

Creates a new `BitSkins` instance.

Expand Down
11 changes: 9 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ module.exports = class BitSkins {
*
* @param {String} apiKey API key
* @param {String} totpKey TOTP key
* @param {String=} appId App ID (defaults to CS:GO if not specified)
* @return {BitSkins} BitSkins instance
*/
constructor(apiKey, totpKey) {
constructor(apiKey, totpKey, appId) {

this.totpKey = totpKey;
this.apiKey = apiKey;
this.appId = appId;

this._req = request.defaults({

Expand All @@ -46,10 +48,15 @@ module.exports = class BitSkins {
* POST payload
* @type {Object}
*/
const body = Object.assign({ code: totp.gen(base32.decode(this.totpKey)),
var body = Object.assign({ code: totp.gen(base32.decode(this.totpKey)),
api_key: this.apiKey },
options);

if (typeof this.appId !== 'undefined')
{
body.app_id = this.appId;
}

return this._req(method, { body: body });

}
Expand Down