Files
shields/services/steam/steam-base.js
T
Paul MelnikowandGitHub 07b282fa1f Enforce property shorthand (#2243)
I had to track down the right lint rule for this. We have no-useless-rename for destructuring and import/export. The one for object literals is object-shorthand.
2018-11-01 13:46:23 -04:00

49 lines
1.2 KiB
JavaScript

'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,
errorMessages: {
400: 'bad request',
},
options,
})
}
}