This repository has been archived by the owner on Jan 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
493 additions
and
512 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
language: node_js | ||
node_js: | ||
- 6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,29 @@ | ||
# championgg-api-node | ||
A node module wrapper for the Champion.GG API | ||
# Node.js Client for the Champion.GG API | ||
|
||
[![NPM](https://nodei.co/npm/@solomid/node-gg.png?mini=true)](https://www.npmjs.com/package/@solomid/node-gg) | ||
|
||
[![Build Status via Travis CI](https://travis-ci.org/solomidnet/championgg-api-node.svg?branch=master)](https://travis-ci.org/solomidnet/championgg-api-node) | ||
|
||
The official Champion.GG API Node.js Client. | ||
|
||
# installation | ||
``` | ||
npm i @solomid/node-gg | ||
``` | ||
|
||
If you really need an ES5 version: | ||
``` | ||
npm i @solomid/[email protected] | ||
``` | ||
|
||
# usage | ||
First, instantiate the wrapper with your api key | ||
``` | ||
var GG = require('node-gg'); | ||
var gg = GG.init('YOUR_KEY'); | ||
const GG = require('node-gg'); | ||
const gg = GG.init('YOUR_KEY'); | ||
``` | ||
|
||
Then you gain access to all current endpoints of the API! All but initialization require a callback function and some also require either `role` or `champion_name`, along with an optional object with ...options. These options are passed as query string params and are `page` and `limit` | ||
Then you gain access to all current endpoints of the API! All but initialization require a callback function and some also require either `role` or `champion_name`, along with an optional object with ...options. These options are passed as query string params and are `page` and `limit`. | ||
|
||
The methods are: | ||
|
||
|
@@ -58,6 +68,3 @@ Method | Parameters | | |
|
||
## contributing | ||
Feel free to contribute, let's just try to keep it readable :) | ||
|
||
## Release History | ||
* 1.0.0 Initial release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
const { request, resolve, error } = require('./utils'); | ||
|
||
const base = '/champion'; | ||
|
||
function all (cb) { | ||
request(base, module.key, (err, res) => { | ||
if (err) throw err; | ||
resolve(res, cb); | ||
}); | ||
} | ||
|
||
function specific(name, cb) { | ||
if (!name || typeof name !== 'string') throw new Error(error.champ); | ||
|
||
request(`${base}/${name}`, module.key, (err, res) => { | ||
if (err) throw err; | ||
resolve(res, cb); | ||
}); | ||
} | ||
|
||
function general(name, cb) { | ||
if (!name || typeof name !== 'string') throw new Error(error.champ); | ||
|
||
resolve(`${base}/${name}/general`, module.key, (err, res) => { | ||
if (err) throw err; | ||
resolve(res, cb); | ||
}); | ||
} | ||
|
||
function generalMatchup (name, cb) { | ||
if (!name || typeof name !== 'string') throw new Error(error.champ); | ||
|
||
request(`${base}/${name}/matchup`, module.key, (err, res) => { | ||
if (err) throw err; | ||
resolve(res, cb); | ||
}); | ||
} | ||
|
||
function specificMatchup (name, enemy, cb) { | ||
if (!name || typeof name !== 'string') throw new Error(error.champ); | ||
if (!enemy || typeof enemy !== 'string') throw new Error(error.enemy); | ||
|
||
request(`${base}/${name}/matchup/${enemy}`, module.key, (err, res) => { | ||
if (err) throw err; | ||
resolve(res, cb); | ||
}); | ||
} | ||
|
||
function mostPopularFinishedItems(name, cb) { | ||
if (!name || typeof name !== 'string') throw new Error(error.champ); | ||
|
||
request(`${base}/${name}/items/finished/mostPopular`, module.key, (err, res) => { | ||
if (err) throw err; | ||
resolve(res, cb); | ||
}); | ||
} | ||
|
||
function mostWinsFinishedItems(name, cb) { | ||
if (!name || typeof name !== 'string') throw new Error(error.champ); | ||
|
||
request(`${base}/${name}/items/finished/mostWins`, module.key, (err, res) => { | ||
if (err) throw err; | ||
resolve(res, cb); | ||
}); | ||
} | ||
|
||
function mostWinsStartingItems(name, cb) { | ||
if (!name || typeof name !== 'string') throw new Error(error.champ); | ||
|
||
request(`${base}/${name}/items/starters/mostWins`, module.key, (err, res) => { | ||
if (err) throw err; | ||
resolve(res, cb); | ||
}); | ||
} | ||
|
||
function mostPopularStartingItems(name, cb) { | ||
if (!name || typeof name !== 'string') throw new Error(error.champ); | ||
|
||
request(`${base}/${name}/items/starters/mostPopular`, module.key, (err, res) => { | ||
if (err) throw err; | ||
resolve(res, cb); | ||
}); | ||
} | ||
|
||
function skillsInfo(name, cb) { | ||
if (!name || typeof name !== 'string') throw new Error(error.champ); | ||
|
||
request(`${base}/${name}/skills`, module.key, (err, res) => { | ||
if (err) throw err; | ||
resolve(res, cb); | ||
}); | ||
} | ||
|
||
function mostWinsSkills(name, cb) { | ||
if (!name || typeof name !== 'string') throw new Error(error.champ); | ||
|
||
request(`${base}/${name}/skills/mostWins`, module.key, (err, res) => { | ||
if (err) throw err; | ||
resolve(res, cb); | ||
}); | ||
} | ||
|
||
function mostPopularSkills(name, cb) { | ||
if (!name || typeof name !== 'string') throw new Error(error.champ); | ||
|
||
request(`${base}/${name}/skills/mostPopular`, module.key, (err, res) => { | ||
if (err) throw err; | ||
resolve(res, cb); | ||
}); | ||
} | ||
|
||
function mostPopularRunes (name, cb) { | ||
if (!name || typeof name !== 'string') throw new Error(error.champ); | ||
|
||
request(`${base}/${name}/runes/mostPopular`, module.key, (err, res) => { | ||
if (err) throw err; | ||
resolve(res, cb); | ||
}); | ||
} | ||
|
||
function mostWinningRunes (name, cb) { | ||
if (!name || typeof name !== 'string') throw new Error(error.champ); | ||
|
||
request(`${base}/${name}/runes/mostWins`, module.key, (err, res) => { | ||
if (err) throw err; | ||
resolve(res, cb); | ||
}); | ||
} | ||
|
||
module.exports = { | ||
init: key => module.key = key, | ||
all: all, | ||
data: { | ||
general: general, | ||
specific: specific | ||
}, | ||
skills: { | ||
info: skillsInfo, | ||
order: { | ||
popular: mostPopularSkills, | ||
winning: mostWinsSkills | ||
} | ||
}, | ||
items: { | ||
starting: { | ||
popular: mostPopularStartingItems, | ||
winning: mostWinsStartingItems | ||
}, | ||
finished: { | ||
popular: mostPopularFinishedItems, | ||
winning: mostWinsFinishedItems | ||
} | ||
}, | ||
runes: { | ||
popular: mostPopularRunes, | ||
winning: mostWinningRunes | ||
}, | ||
matchups: { | ||
general: generalMatchup, | ||
specific: specificMatchup | ||
} | ||
} |
Oops, something went wrong.