Skip to content
This repository has been archived by the owner on Jan 19, 2025. It is now read-only.

Commit

Permalink
Merge pull request #865 from fernando457829/rework/apis-options
Browse files Browse the repository at this point in the history
Rework in apis options
  • Loading branch information
pedrofracassi authored Jun 2, 2019
2 parents 6264dc0 + 6859f08 commit a407d8d
Show file tree
Hide file tree
Showing 22 changed files with 86 additions and 56 deletions.
5 changes: 3 additions & 2 deletions src/apis/Chorus.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ const API_URL = 'https://chorus.fightthe.pw/api'

module.exports = class ChorusAPI extends APIWrapper {
constructor () {
super()
this.name = 'chorus'
super({
name: 'chorus'
})
}

search (query) {
Expand Down
7 changes: 4 additions & 3 deletions src/apis/Crowdin.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ const Crowdin = require('crowdin-without-vulnerability')

module.exports = class CrowdinAPI extends APIWrapper {
constructor () {
super()
this.name = 'crowdin'
this.envVars = ['CROWDIN_API_KEY', 'CROWDIN_PROJECT_ID']
super({
name: 'crowdin',
envVars: ['CROWDIN_API_KEY', 'CROWDIN_PROJECT_ID']
})
}

load () {
Expand Down
7 changes: 4 additions & 3 deletions src/apis/DBL.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ const API_URL = 'https://discordbots.org/api'

module.exports = class DBL extends APIWrapper {
constructor () {
super()
this.name = 'dbl'
this.envVars = ['DBL_TOKEN']
super({
name: 'dbl',
envVars: ['DBL_TOKEN']
})
}

searchBots (query, maxValues) {
Expand Down
7 changes: 4 additions & 3 deletions src/apis/DarkSky.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ const API_URL = 'https://api.darksky.net'

module.exports = class DarkSkyAPI extends APIWrapper {
constructor () {
super()
this.name = 'darksky'
this.envVars = ['DARKSKY_KEY']
super({
name: 'darksky',
envVars: 'DARKSKY_KEY'
})
}

// Get
Expand Down
5 changes: 3 additions & 2 deletions src/apis/Deezer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ const API_URL = 'https://api.deezer.com'

module.exports = class DeezerAPI extends APIWrapper {
constructor () {
super()
this.name = 'deezer'
super({
name: 'deezer'
})
}

// Get
Expand Down
7 changes: 4 additions & 3 deletions src/apis/Genius.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ const API_URL = 'https://api.genius.com'

module.exports = class GeniusAPI extends APIWrapper {
constructor () {
super()
this.name = 'genius'
this.envVars = ['GENIUS_API']
super({
name: 'genius',
envVars: ['GENIUS_API']
})
}

// Find a track
Expand Down
7 changes: 4 additions & 3 deletions src/apis/GitHub.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ const API_URL = 'https://api.github.com'

module.exports = class GitHubAPI extends APIWrapper {
constructor () {
super()
this.name = 'github'
this.envVars = ['GITHUB_CLIENT_ID', 'GITHUB_CLIENT_SECRET']
super({
name: 'github',
envVars: ['GITHUB_CLIENT_ID', 'GITHUB_CLIENT_SECRET']
})
}

getUser (username) {
Expand Down
7 changes: 4 additions & 3 deletions src/apis/GoogleMaps.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ const API_URL = 'https://maps.googleapis.com/maps/api'

module.exports = class GoogleMapsAPI extends APIWrapper {
constructor () {
super()
this.name = 'gmaps'
this.envVars = ['GMAPS_KEY']
super({
name: 'gmaps',
envVars: ['GMAPS_KEY']
})
}

// Search
Expand Down
5 changes: 3 additions & 2 deletions src/apis/GoogleTranslate.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ const snekfetch = require('snekfetch')

module.exports = class GoogleTranslate extends APIWrapper {
constructor () {
super()
this.name = 'gtranslate'
super({
name: 'gtranslate'
})
}

/**
Expand Down
5 changes: 3 additions & 2 deletions src/apis/HIBP.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ const USER_AGENT = 'Switchblade-Discord-Bot'

module.exports = class HIBP extends APIWrapper {
constructor () {
super()
this.name = 'hibp'
super({
name: 'hibp'
})
}

getBreaches (query) {
Expand Down
5 changes: 3 additions & 2 deletions src/apis/Icecast.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ const IcecastParser = require('icecast-parser')

module.exports = class Icecast extends APIWrapper {
constructor () {
super()
this.name = 'icecast'
super({
name: 'icecast'
})
}

fetchMetadata (url) {
Expand Down
7 changes: 4 additions & 3 deletions src/apis/LastFm.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ const API_URL = 'http://ws.audioscrobbler.com/2.0/'

module.exports = class LastFM extends APIWrapper {
constructor () {
super()
this.name = 'lastfm'
this.envVars = ['LASTFM_KEY', 'LASTFM_SECRET']
super({
name: 'lastfm',
envVars: ['LASTFM_KEY', 'LASTFM_SECRET']
})
}

// GET METHODS
Expand Down
6 changes: 4 additions & 2 deletions src/apis/LeagueOfLegends.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ const API_URL = 'https://ddragon.leagueoflegends.com'

module.exports = class LeagueOfLegends extends APIWrapper {
constructor () {
super()
this.name = 'lol'
super({
name: 'lol'
})

this.version = null
}

Expand Down
5 changes: 3 additions & 2 deletions src/apis/Mixer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ const API_URL = 'https://mixer.com/api/v1'

module.exports = class MixerAPI extends APIWrapper {
constructor () {
super()
this.name = 'mixer'
super({
name: 'mixer'
})
}

getUser (id) {
Expand Down
5 changes: 3 additions & 2 deletions src/apis/Soundcloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ const APP_SCRIPT_CLIENT_ID_REGEX = /,client_id:"([a-zA-Z0-9-_]+)"/

module.exports = class SoundcloudAPI extends APIWrapper {
constructor () {
super()
this.name = 'soundcloud'
super({
name: 'soundcloud'
})

this.lastClientIdUpdate = 0
this.clientId = null
Expand Down
8 changes: 5 additions & 3 deletions src/apis/Spotify.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ const API_URL = 'https://api.spotify.com/v1'

module.exports = class SpotifyAPI extends APIWrapper {
constructor () {
super()
this.name = 'spotify'
this.envVars = ['SPOTIFY_CLIENT_ID', 'SPOTIFY_CLIENT_SECRET']
super({
name: 'spotify',
envVars: ['SPOTIFY_CLIENT_ID', 'SPOTIFY_CLIENT_SECRET']
})

this.token = null
}

Expand Down
7 changes: 4 additions & 3 deletions src/apis/Steam.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ const Steam = require('steamapi')

module.exports = class SteamAPI extends APIWrapper {
constructor () {
super()
this.name = 'steam'
this.envVars = ['STEAM_API_KEY']
super({
name: 'steam',
envVars: ['STEAM_API_KEY']
})
}

load () {
Expand Down
5 changes: 4 additions & 1 deletion src/apis/SteamLadder.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ const SteamLadder = require('steamladder')

module.exports = class SteamLadderAPI extends APIWrapper {
constructor () {
super()
super({
name: 'steamladder',
envVars: ['STEAM_LADDER_API_KEY']
})
this.name = 'steamladder'
this.envVars = ['STEAM_LADDER_API_KEY']
}
Expand Down
7 changes: 4 additions & 3 deletions src/apis/Tumblr.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ const API_URL = 'https://api.tumblr.com/v2'

module.exports = class TumblrAPI extends APIWrapper {
constructor () {
super()
this.name = 'tumblr'
this.envVars = ['TUMBLR_API_KEY']
super({
name: 'tumblr',
envVars: ['TUMBLR_API_KEY']
})
}

/**
Expand Down
7 changes: 4 additions & 3 deletions src/apis/Twitch.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ const API_URL = 'https://api.twitch.tv/helix'

module.exports = class TwitchAPI extends APIWrapper {
constructor () {
super()
this.name = 'twitch'
this.envVars = ['TWITCH_CLIENT_ID']
super({
name: 'twitch',
envVars: ['TWITCH_CLIENT_ID']
})
}

getUser (id) {
Expand Down
7 changes: 4 additions & 3 deletions src/apis/Youtube.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ const { google } = require('googleapis')

module.exports = class YoutubeAPI extends APIWrapper {
constructor () {
super()
this.name = 'youtube'
this.envVars = ['YOUTUBE_API_KEY']
super({
name: 'youtube',
envVars: ['YOUTUBE_API_KEY']
})
}

load () {
Expand Down
11 changes: 8 additions & 3 deletions src/structures/APIWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@
* @constructor
*/
module.exports = class APIWrapper {
constructor () {
this.name = ''
this.envVars = []
/**
* @param {Object} [options] - Options
* @param {string} options.name - Name
* @param {string[]} [options.envVars] - Required Environment Variables
*/
constructor (options = {}) {
this.name = options.name
this.envVars = options.envVars || []
}

/**
Expand Down

0 comments on commit a407d8d

Please sign in to comment.