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

Add [Steam] Service #2140

Merged
merged 3 commits into from Oct 10, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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,
})
}
}