Skip to content

Commit

Permalink
Add [Steam] Service (#2140)
Browse files Browse the repository at this point in the history
* Add Steam Service
  • Loading branch information
TagnumElite authored and RedSparr0w committed Oct 10, 2018
1 parent 0265d4e commit 74b6c4a
Show file tree
Hide file tree
Showing 3 changed files with 597 additions and 0 deletions.
48 changes: 48 additions & 0 deletions services/steam/steam-base.js
@@ -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,
})
}
}

0 comments on commit 74b6c4a

Please sign in to comment.