Skip to content
This repository has been archived by the owner on Sep 12, 2019. It is now read-only.

Removing Runtime Babel Dependency #35

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
4 changes: 0 additions & 4 deletions .babelrc

This file was deleted.

112 changes: 86 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

This is a Javascript API client wrapper for [Vainglory](http://vainglorygame.com). If you run into problems or find bugs, [file an issue](https://github.com/seripap/vainglory/issues).

## Requirements

```
Node 6>
```

## Installation

```
Expand All @@ -27,7 +33,7 @@ Base options can be modified by passing an object during initalization.
__Properties__
- `host` [*String*] - HTTP Url to call
- `title` [*String*] - X-TITLE-ID modifier
- `region` [*String*] - Region of which game data to request (`na`, `eu`, `sa`, `ea`, `sg`) [Reference](https://developer.vainglorygame.com/docs#regions)
- `region` [*String*] - Region of which game data to request (`na`, `eu`, `sa`, `ea`, `sg`, `cn`) [Reference](https://developer.vainglorygame.com/docs#regions)

```javascript
import Vainglory from 'vainglory';
Expand Down Expand Up @@ -413,13 +419,15 @@ For fields in `participant` such as `actor` or `itemGrants`, server will return
[Ref](https://developer.vainglorygame.com/docs#matches)

- `.assets` - Array of [Asset](#assetModel)
- `.createdAt`
- `.duration`
- `.gameMode`
- `.patchVersion`
- `.shardId`
- `.stats`
- `.titleId`
- `.createdAt` - a string, the match timestamp, suitable for passing to JavaScript `Date` constructor. Note that this is the time when the match was initiated, which is the start of the hero pick phase. To find when the first spawns on the map were, see the timestamps on individual events in the telemetry data.
- `.duration` - an integer, match duration in seconds
- `.gameMode` - a string, such as `"Casual 5v5"` ([see full list here](src/models/resources/gameModes.js))
- `.patchVersion` - a string, which Vainglory update the match was played on, such as `"3.1"`
- `.shardId` - a string, the region from which the match was fetched, in lower case, such as `"na"`
- `.stats` - an object with these attributes:
- `endGameReason` - a string, such as `"victory"` or `"surrender"`
- `queue` - a string, such as `"5v5_pvp_ranked"`
- `.titleId` - always the string `"semc-vainglory"`
- `.rosters` - Array of [Roster](#rosterModel)

<a name="assetModel" />
Expand All @@ -428,12 +436,12 @@ For fields in `participant` such as `actor` or `itemGrants`, server will return

[Ref](https://developer.vainglorygame.com/docs#telemetry)

- `.URL`
- `.contentType`
- `.createdAt`
- `.description`
- `.filename`
- `.name`
- `.URL` - a string, the URL of where to download the asset
- `.contentType` - this field is not always present
- `.createdAt` - match timestamp as a string, suitable for passing to JavaScript `Date` constructor
- `.description` - this field is not always present, and is sometimes the empty string
- `.filename` - meaning uncertain
- `.name` - a string, such as `"telemetry"`
- `.resolve()` - Returns promise; resolves `.URL` data

<a name="rosterModel" />
Expand All @@ -442,7 +450,14 @@ For fields in `participant` such as `actor` or `itemGrants`, server will return

[Ref](https://developer.vainglorygame.com/docs#rosters)

- `.stats`
- `.stats` - an object with these attributes:
- `acesEarned` - an integer, total number of aces earned by the team in the match
- `gold` - an integer, total gold earned by the team in the match
- `heroKills` - an integer, total number of hero kills earned by the team in the match
- `krakenCaptures` - an integer, total number of times the team captured the Kraken in the match
- `side` - a string, either `"left/blue"` or `"right/red"`
- `turretKills` - an integer, total number of turrets the team destroyed in the match
- `turretsRemaining` - an integer, total number of turrets the team had remaining on their side at match end
- `.participants` - Array of [Participant](#participantModel)

<a name="participantModel" />
Expand All @@ -451,10 +466,33 @@ For fields in `participant` such as `actor` or `itemGrants`, server will return

[Ref](https://developer.vainglorygame.com/docs#participants)

- `._actor`
- `.actor`
- `._stats`
- `.stats`
- `._actor` - original actor data before this module did cleanup on it
- `.actor` - name of hero used by this participant, as a string ([see hero name cleanup details here](https://github.com/seripap/vainglory/blob/master/src/models/participant.js#L42))
- `._stats` - original stats data before this module did cleanup on it
- `.stats` - cleaned up participant stats, an object with these attributes:
- `assists` - an integer, the number of assists the player did (the third number in KDA)
- `crystalMineCaptures` - an integer, the number of times the player killed the crystal sentry
- `deaths` - an integer, number of times the player died (the second number in KDA)
- `farm` - an integer, meaning unclear, possibly number of monsters/minions killed
- `firstAfkTime` - an integer, the number of seconds into the match the player first went AFK, or -1 if they never did
- `gold` - a number (not usually an integer), total gold earned by this player throughout the match
- `goldMineCaptures` - an integer, the number of times the player killed the gold miner
- `itemGrants` - an object whose keys are the names of the items the player purchased, and whose values are the number of times the player purchased that item; example: `{"Weapon Blade":2,"Six Sins":1,"Heavy Steel":1,"Sorrowblade":1,...}`
- `itemSells` - similar in structure to the previous, but for selling items
- `itemUses` - an object whose keys are the names of items the player used, and whose values are the number of times the player used the item; example: `{"Travel Boots":3,"Scout Cam":3,...}`
- `items` - array of strings, all items the player possessed at the end of the match
- `jungleKills` - number of kills in jungle camps
- `karmaLevel` - a string, one of the three [listed here](src/models/resources/karma.js)
- `kills` - an integer, the number of kills the player did (the first number in KDA)
- `krakenCaptures` - an integer, the number of times the player captured the Kraken
- `level` - an integer, the level of the player (in the sense of gaining experience post-match to level up your account)
- `minionKills` - an integer, the number of minions the player killed (including jungle creeps)
- `nonJungleMinionKills` - an integer, the number of minions the player killed (excluding jungle creeps)
- `skillTier` - a string such as `"Rock Solid - Gold"`, as provided by [this lookup table](src/models/resources/skillTiers.js)
- `skinKey` - a string naming the skin the player used, such as `"Gwen_DefaultSkin"`
- `turretCaptures` - an integer, the number of turrets the player destroyed
- `wentAfk` - a boolean (true or false), whether the player went AFK during the match
- `winner` - a boolean (true or false), whether the player was on the winning team
- `.player` - [Player](#playerModel)

<a name="playersModel" />
Expand All @@ -467,10 +505,32 @@ For fields in `participant` such as `actor` or `itemGrants`, server will return

### Player

- `.name`
- `.shardId`
- `.stats`
- `.titleId`
- `.skillTier`
- `.karmaLevel`
- `.createdAt`
- `.name` - a string, the player's IGN
- `.shardId` - region from which the match was fetched, in lower case (e.g., `"na"`)
- `.stats` - an object with the following attributes:
- `elo_earned_season_4` - deprecated; use `rankPoints` instead, documented below
- `elo_earned_season_5` - deprecated; use `rankPoints` instead, documented below
- `elo_earned_season_6` - deprecated; use `rankPoints` instead, documented below
- `elo_earned_season_7` - deprecated; use `rankPoints` instead, documented below
- `elo_earned_season_8` - deprecated; use `rankPoints` instead, documented below
- `elo_earned_season_9` - deprecated; use `rankPoints` instead, documented below
- `gamesPlayed` - object whose keys are various match types (aral, blitz, blitz_rounds, casual, casual_5v5, ranked, etc.) and whose values are the number of times the player has played that match type
- `guildTag` - a string of up to 4 characters, the player's guild tag, or the empty string if the player has no guild
- `karmaLevel` - an integer, one of the three [listed here](src/models/resources/karma.js)
- `level` - an integer, the level of the player (in the sense of gaining experience post-match to level up your account)
- `lifetimeGold` - meaning unclear
- `lossStreak` - number of matches the player has lost in a row, or 0 if the last match was a win (but sometimes this number and `winStreak` are both zero, impossibly)
- `played` - meaning unclear
- `played_aral` - deprecated; use `gamesPlayed` instead, documented above
- `played_blitz` - deprecated; use `gamesPlayed` instead, documented above
- `played_casual` - deprecated; use `gamesPlayed` instead, documented above
- `played_ranked` - deprecated; use `gamesPlayed` instead, documented above
- `rankPoints` - an object whose keys are `"blitz"` and `"ranked"` and whose values are the player's precise numerical ranks in each of those match types (5v5 rank values not yet supplied)
- `skillTier` - an integer, which can be decoded by [this lookup table](src/models/resources/skillTiers.js)
- `winStreak` - number of matches the player has lost in a row, or 0 if the last match was a win (but sometimes this number and `lossStreak` are both zero, impossibly)
- `wins` - an integer, number of games won
- `xp` - an integer, number of experience points earned (in post-match rewards, for leveling the player's account)
- `.titleId` - always the string `"semc-vainglory"`
- `.skillTier` - an object containing both `serverName` and `name` properties, from the list in [this lookup table](src/models/resources/skillTiers.js)
- `.karmaLevel` - an object containing both `serverName` and `name` properties, from the list in [this lookup table](src/models/resources/karma.js)
- `.createdAt` - meaning unclear; this attribute is not always present
38 changes: 13 additions & 25 deletions dist/Errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,20 @@
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.NETWORK_ERROR = exports.NOT_ACCEPTABLE = exports.OFFLINE = exports.NOT_FOUND = exports.NO_BODY = exports.INTERNAL = exports.UNKNOWN = exports.UNAUTHORIZED = exports.RATE_LIMIT = undefined;

var _extends2 = require('babel-runtime/helpers/extends');

var _extends3 = _interopRequireDefault(_extends2);

exports.normalizeError = normalizeError;

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var RATE_LIMIT = exports.RATE_LIMIT = 'Request rate limited. Free for non-commercial use for up to 10 requests per minute! To increase your rate limit, please contact api@superevilmegacorp.com';
var UNAUTHORIZED = exports.UNAUTHORIZED = 'Unauthorized Access. invalid API key provided.';
var UNKNOWN = exports.UNKNOWN = 'Unknown error, please check your request and try again.';
var INTERNAL = exports.INTERNAL = 'Internal Server Error.';
var NO_BODY = exports.NO_BODY = 'No body returned from response.';
var NOT_FOUND = exports.NOT_FOUND = 'The specified object could not be found.';
var OFFLINE = exports.OFFLINE = 'API is currently offline, try again later.';
var NOT_ACCEPTABLE = exports.NOT_ACCEPTABLE = 'You requested a format that is\'t JSON';
var NETWORK_ERROR = exports.NETWORK_ERROR = 'Network error, check host name.';

function normalizeError() {
var messages = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Unknown Client error';
var attachments = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};

return (0, _extends3.default)({
const RATE_LIMIT = exports.RATE_LIMIT = 'Request rate limited. Free for non-commercial use for up to 10 requests per minute! To increase your rate limit, please contact api@superevilmegacorp.com';
const UNAUTHORIZED = exports.UNAUTHORIZED = 'Unauthorized Access. invalid API key provided.';
const UNKNOWN = exports.UNKNOWN = 'Unknown error, please check your request and try again.';
const INTERNAL = exports.INTERNAL = 'Internal Server Error.';
const NO_BODY = exports.NO_BODY = 'No body returned from response.';
const NOT_FOUND = exports.NOT_FOUND = 'The specified object could not be found.';
const OFFLINE = exports.OFFLINE = 'API is currently offline, try again later.';
const NOT_ACCEPTABLE = exports.NOT_ACCEPTABLE = 'You requested a format that is\'t JSON';
const NETWORK_ERROR = exports.NETWORK_ERROR = 'Network error, check host name.';

function normalizeError(messages = 'Unknown Client error', attachments = {}) {
return Object.assign({
errors: true,
messages: messages
messages
}, attachments);
}
Loading