-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
3 changed files
with
597 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
'use strict' | ||
|
||
const BaseJsonService = require('../base-json') | ||
|
||
/** | ||
* The steam api is based like /{interface}/{method}/v{version}/ | ||
* @see https://partner.steamgames.com/doc/webapi_overview#2 | ||
*/ | ||
module.exports = class BaseSteamAPI extends BaseJsonService { | ||
/** | ||
* Steam API Interface | ||
* @see https://partner.steamgames.com/doc/webapi_overview#2 | ||
*/ | ||
static get interf() { | ||
throw new Error(`interf() was not implement for ${this.name}`) | ||
} | ||
|
||
/** | ||
* Steam API Method | ||
* @see https://partner.steamgames.com/doc/webapi_overview#2 | ||
*/ | ||
static get method() { | ||
throw new Error(`method() was not implement for ${this.name}`) | ||
} | ||
|
||
/** | ||
* Steam API Version | ||
* @see https://partner.steamgames.com/doc/webapi_overview#2 | ||
*/ | ||
static get version() { | ||
throw new Error(`version() was not implement for ${this.name}`) | ||
} | ||
|
||
async fetch({ schema, options }) { | ||
const interf = this.constructor.interf | ||
const method = this.constructor.method | ||
const version = this.constructor.version | ||
const url = `https://api.steampowered.com/${interf}/${method}/v${version}/?format=json` | ||
return this._requestJson({ | ||
url, | ||
schema: schema, | ||
errorMessages: { | ||
400: 'bad request', | ||
}, | ||
options: options, | ||
}) | ||
} | ||
} |
Oops, something went wrong.