Continue to implement #2698: - Add `core/base-service/index.js` (but hold off on moving the things it imports) - Add shortcuts in `services/index.js` for Base*Service, errors, and deprecatedService. This file will be streamlined later to avoid cluttering it with rarely used bits. - Apply consistent ordering of imports and use of `module.exports` in testers. - Remove some renaming of imports. - Remove obsolete tests here and there.
49 lines
1.2 KiB
JavaScript
49 lines
1.2 KiB
JavaScript
'use strict'
|
|
|
|
const { BaseJsonService } = require('..')
|
|
|
|
/**
|
|
* 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,
|
|
errorMessages: {
|
|
400: 'bad request',
|
|
},
|
|
options,
|
|
})
|
|
}
|
|
}
|