RitoPlz 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +9 -0
- data/LICENSE.txt +21 -0
- data/README.md +82 -0
- data/Rakefile +6 -0
- data/RitoPlz.gemspec +26 -0
- data/bin/console +10 -0
- data/bin/setup +7 -0
- data/lib/RitoPlz.rb +41 -0
- data/lib/RitoPlz/API/README.md +75 -0
- data/lib/RitoPlz/API/base.rb +11 -0
- data/lib/RitoPlz/API/champion.rb +28 -0
- data/lib/RitoPlz/API/champion_mastery.rb +43 -0
- data/lib/RitoPlz/API/current_game.rb +27 -0
- data/lib/RitoPlz/API/exceptions.rb +123 -0
- data/lib/RitoPlz/API/featured_games.rb +23 -0
- data/lib/RitoPlz/API/game.rb +23 -0
- data/lib/RitoPlz/API/league.rb +54 -0
- data/lib/RitoPlz/API/match.rb +23 -0
- data/lib/RitoPlz/API/match_list.rb +23 -0
- data/lib/RitoPlz/API/request.rb +100 -0
- data/lib/RitoPlz/API/static_data.rb +93 -0
- data/lib/RitoPlz/API/stats.rb +29 -0
- data/lib/RitoPlz/API/status.rb +28 -0
- data/lib/RitoPlz/API/summoner.rb +48 -0
- data/lib/RitoPlz/API/team.rb +30 -0
- data/lib/RitoPlz/API/tournament.rb +51 -0
- data/lib/RitoPlz/client.rb +78 -0
- data/lib/RitoPlz/configuration.rb +10 -0
- data/lib/RitoPlz/version.rb +3 -0
- data/riot.txt +1 -0
- metadata +136 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 410c20f3f3797b9a40552076870c2503d4df3bf3
|
|
4
|
+
data.tar.gz: d08ec90bd1dce5c095cb7511bdf4e219b9604fce
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: d241d3f7cfea0605994845a5566acf4f108d58f7ddb9e48f05ecdac4f919d6244effce04f393e0babeb37beafc55c928ae0248bdab14fbccda66877821a594c4
|
|
7
|
+
data.tar.gz: 0614774dac244704f7dec90da8745c0d32892b1f1c4fc57484abcd89a0034296f225e4b565c1b7251094f090d60d03e6bf511b9fecbb319af996cec8de8ac606
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016 Luke Jones
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# RitoPlz
|
|
2
|
+
[](https://travis-ci.org/gjh33/RitoPlz)
|
|
3
|
+
|
|
4
|
+
RitoPlz is an independently developed easy to use API wrapper for Riot Games API.
|
|
5
|
+
The main goal of this project is to provide a very clean, easy to use API which should not result in any frustration. Should you find yourself frustrated please open a Bug Report so I can make the necessary changes. The source code should also be simple and easy to read.
|
|
6
|
+
|
|
7
|
+
##Goals
|
|
8
|
+
The goals for this project are very important. If you feel the project is not meeting these goals, please make a bug report or fork the project.
|
|
9
|
+
|
|
10
|
+
* Simplicity. This wrapper should be stupid simple. No meta programming. No hidden bullshit. Very clear. If you dont like something about this gem, you should be able to manipulate it without issue to your needs.
|
|
11
|
+
* Well documented. You should have no questions if you've read all the documentation on github. You should never be confused, and this should all be very easy.
|
|
12
|
+
* No frustration. The reason for the first 2 goals is to minimize frustration. I'm sick and tired of using API wrappers only to find they lack a feature, or have a bug, and it's impossible to figure out why.
|
|
13
|
+
* Barebones. This should be barebones and as close to riot's api as possible. No model associations, no fancy features. This gem should be what you use when you want to make a fancier wrapper.
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
Add this line to your application's Gemfile:
|
|
18
|
+
|
|
19
|
+
```ruby
|
|
20
|
+
gem 'RitoPlz'
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
And then execute:
|
|
24
|
+
|
|
25
|
+
$ bundle
|
|
26
|
+
|
|
27
|
+
Or install it yourself as:
|
|
28
|
+
|
|
29
|
+
$ gem install RitoPlz
|
|
30
|
+
|
|
31
|
+
## Usage
|
|
32
|
+
|
|
33
|
+
### Configuration
|
|
34
|
+
Before using RitoPlz you must first configure the application with your api key. Other configuration options are available and will be listed below
|
|
35
|
+
|
|
36
|
+
```ruby
|
|
37
|
+
RitoPlz.configure do |config|
|
|
38
|
+
config.api_key = "my_awesome_riot_api_key" #your secret api key provided to you by riot
|
|
39
|
+
config.default_region = :na #default region when building the client
|
|
40
|
+
end
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
It's recommended to never commit your api key. A good practice is to use environment variables. For dev use `gem 'dot-env'` to configure environment variables, then on your production server set an environment variable. Ruby has a built in `ENV['KEY']` command to access environment variables. For example:
|
|
44
|
+
```ruby
|
|
45
|
+
RitoPlz.configure do |config|
|
|
46
|
+
config.api_key = ENV['RIOT_SECRET_KEY'] #Where 'RIOT_SECRET_KEY' is the name of your environment variable
|
|
47
|
+
end
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Building the client
|
|
51
|
+
All api calls should be made through the client. Though it is possible to instantiate the endpoint classes directly, it is recommended you use the client which provides default configuration and a clean interface for making calls. You can build the client like so:
|
|
52
|
+
```ruby
|
|
53
|
+
client = RitoPlz::Client.new #Client with the region set to the configured default region (by default :na)
|
|
54
|
+
client = RitoPlz::Client.new(region: :euw) #Client with a region different from the default region
|
|
55
|
+
```
|
|
56
|
+
Clients are bound to the region you instantiate them with. If your application requires the use of multiple regions, It's recommended you create a client for each region you'll require. Clients are not heavy and can be created frequently without worry.
|
|
57
|
+
|
|
58
|
+
### Making an api call
|
|
59
|
+
This API wrapper is designed to closely mimick the api documentation on Riot's website. It's recommended that you read through their documentation when using this wrapper. For example if you wanted to make a call to summoner api and get a summoner by name, on Riot's site they provide the documenation for "/api/lol/{region}/v1.4/summoner/by-name/{summonerNames}". In RitoPlz you would write
|
|
60
|
+
```ruby
|
|
61
|
+
client = RitoPlz::Client.new
|
|
62
|
+
client.summoner.by_names("summonerA", "summonerB")
|
|
63
|
+
```
|
|
64
|
+
The API endpoints return response objects from the net/http standard ruby library. This way you have full access to all the response data, headers, and more.
|
|
65
|
+
|
|
66
|
+
The best way to learn to use the api wrapper, is to type what feels natural when reading the riot api. If that doesn't work, read the source code. It's very easy to understand. Every endpoint is in a class inside lib/RitoPlz/API/. Reading that class you'll see the available methods. This wrapper is designed to be stupid simple, so you should have no trouble reading, expanding upon, and tinkering with the code.
|
|
67
|
+
|
|
68
|
+
To see more in depth documentation, read the readme inside RiotPlz/API/
|
|
69
|
+
|
|
70
|
+
## Development
|
|
71
|
+
|
|
72
|
+
Clone the git repository and then run 'bundle install'. The project should now run. You can check to be sure by running 'rspec' and checking all tests are passing.
|
|
73
|
+
|
|
74
|
+
You have access to a console courtesy of pry in bin/console
|
|
75
|
+
|
|
76
|
+
## Contributing
|
|
77
|
+
|
|
78
|
+
1. Fork it ( https://github.com/[my-github-username]/RitoPlz/fork )
|
|
79
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
80
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
81
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
82
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/RitoPlz.gemspec
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'RitoPlz/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "RitoPlz"
|
|
8
|
+
spec.version = RitoPlz::VERSION
|
|
9
|
+
spec.authors = ["Luke Jones"]
|
|
10
|
+
spec.email = ["manhappylife@yahoo.ca"]
|
|
11
|
+
|
|
12
|
+
spec.summary = %q{A simple riot api wrapper with the aim of being easy to use and well documented.}
|
|
13
|
+
spec.description = %q{The aim of RitoPlz is to provide a simple, clean, and easy to use ruby API wrapper. My priority is to provide a gem that is well documented and that you should never get frustrated with. If I fail to meet these goals please open a bug report in GitHub so I can fix the problem.}
|
|
14
|
+
spec.homepage = "http://github.com/gjh33/RitoPlz"
|
|
15
|
+
spec.license = "MIT"
|
|
16
|
+
|
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
18
|
+
spec.bindir = "exe"
|
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
20
|
+
spec.require_paths = ["lib"]
|
|
21
|
+
|
|
22
|
+
spec.add_development_dependency "bundler"
|
|
23
|
+
spec.add_development_dependency "rake"
|
|
24
|
+
spec.add_development_dependency "pry"
|
|
25
|
+
spec.add_development_dependency "rspec"
|
|
26
|
+
end
|
data/bin/console
ADDED
data/bin/setup
ADDED
data/lib/RitoPlz.rb
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
require "RitoPlz/version"
|
|
2
|
+
require "RitoPlz/configuration"
|
|
3
|
+
require "RitoPlz/client"
|
|
4
|
+
|
|
5
|
+
module RitoPlz
|
|
6
|
+
REGION_TO_PLATFORM = {
|
|
7
|
+
na: :na1,
|
|
8
|
+
euw: :euw1,
|
|
9
|
+
eune: :eun1,
|
|
10
|
+
jp: :jp1,
|
|
11
|
+
kr: :kr,
|
|
12
|
+
oce: :oc1,
|
|
13
|
+
br: :br1,
|
|
14
|
+
lan: :la1,
|
|
15
|
+
las: :la2,
|
|
16
|
+
ru: :ru,
|
|
17
|
+
tr: :tr1,
|
|
18
|
+
pbe: :pbe1
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
class << self
|
|
22
|
+
attr_accessor :configuration
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def self.configuration
|
|
26
|
+
@configuration ||= Configuration.new
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def self.configure
|
|
30
|
+
yield configuration
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def self.reset
|
|
34
|
+
@configuration = Configuration.new
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def self.to_platform(region)
|
|
38
|
+
region = region.to_sym
|
|
39
|
+
REGION_TO_PLATFORM[region]
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# RitoPlz API Documentation
|
|
2
|
+
|
|
3
|
+
## Method Naming Convention
|
|
4
|
+
RitoPlz has a somewhat simple naming convention. RitoPlz follows the riot api documentation. However there are a few exceptions where Riot's documentation doesn't suit the needs of an abstract api wrapper. We'll cover these rules here. Alternatively you could just go read the source code and figure out what all the methods are called.
|
|
5
|
+
|
|
6
|
+
### ID values
|
|
7
|
+
When an api call requires ID values to be passed, the endpoint is named based on ambiguity. For example, if you want to get champion data by id, you can call
|
|
8
|
+
```ruby
|
|
9
|
+
client = RitoPlz::Client.new
|
|
10
|
+
client.champion.by_id
|
|
11
|
+
```
|
|
12
|
+
Here RitoPlz uses `by_id` because it is clear who the id belongs to. If not specified the id belongs to the name of the api, in this case "champion". However in another case where the id value is ambiguous like in the league api, RitoPlz uses the convention of `by_resource_id`. For example if you wanted to get the league data for a player:
|
|
13
|
+
```ruby
|
|
14
|
+
client = RitoPlz::Client.new
|
|
15
|
+
client.league.by_player_id(1)
|
|
16
|
+
```
|
|
17
|
+
As you can see since the id doesn't belong to the league itself, RitoPlz names the id.
|
|
18
|
+
|
|
19
|
+
Sometimes more complexity is needed. For example lets say you want the runs for a specific summoner. Here you must request the resource by the id.
|
|
20
|
+
```ruby
|
|
21
|
+
client = RitoPlz::Client.new
|
|
22
|
+
client.summoner.runes_by_player_ids(1, 2, 3, 4)
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### All resources
|
|
26
|
+
When an api returns all resources, RitoPlz uses simlar convention to IDs. When it's not ambiguous and the requested resource matches the name of the api, you can simply call `all`. An example is the champion api:
|
|
27
|
+
```ruby
|
|
28
|
+
client = RitoPlz::Client.new
|
|
29
|
+
client.champion.all
|
|
30
|
+
```
|
|
31
|
+
However when it's ambiguous what's being requested, RiotPlz uses `all_resources` convention. For example:
|
|
32
|
+
```ruby
|
|
33
|
+
client = RitoPlz::Client.new
|
|
34
|
+
client.static_data.all_champions
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Multiple parameters
|
|
38
|
+
Some Riot APIs take a list of names, ids, etc in an api call. RitoPlz supports this using ruby's * operator. You can provide the list directly in the arguments, or pass an array. For example:
|
|
39
|
+
```ruby
|
|
40
|
+
client = RitoPlz::Client.new
|
|
41
|
+
client.league.by_player_ids(0, 1, 2, 3) #passed directly
|
|
42
|
+
|
|
43
|
+
player_ids = [0, 1, 2, 3]
|
|
44
|
+
client.league.by_player_ids(player_ids) #passed as an array
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Special APIs
|
|
48
|
+
Some of Riot's APIs are special to a specific resource. For example champion mastery. RitoPlz handles this by passing the param to the api object upon instantiation. When calling from the client, the argument goes in the direct method call like so:
|
|
49
|
+
```ruby
|
|
50
|
+
client = RitoPlz::Client.new
|
|
51
|
+
client.champion_mastery(288831).all_champions #the player id is passed into the first method call, and all chained methods after will use that id
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Right now there are only two that do this: stats, and championmastery
|
|
55
|
+
|
|
56
|
+
### Optional parameters
|
|
57
|
+
Optional parameters are easy with RitoPlz. Let's use matchlist as an example. You can pull up the api on Riot's site to see what's up.
|
|
58
|
+
```ruby
|
|
59
|
+
client = RitoPlz::Client.new
|
|
60
|
+
client.match_list.by_player_id(beginIndex: 1000, endIndex: 5000, seasons: [:SEASON2014, :SEASON2015, :SEASON2016])
|
|
61
|
+
```
|
|
62
|
+
The optional parameters are simply passed in as a hash to the endpoint. Easy right? Your arrays are automatically converted to a comma seperated string that Riot's API will receive.
|
|
63
|
+
|
|
64
|
+
### Tournament API
|
|
65
|
+
Riot's tournament api made it difficult for RitoPlz to use the usual convention. I recommend reading the source code, however I will do my best to explain.
|
|
66
|
+
|
|
67
|
+
Some API require body and query params. RitoPlz combines these into 1 hash for parameters. If the parameter is a path parameter (in the path for the api call, not params) then it is a mandatory parameter for the method. The only exception being generating a tournament code. For this api, tournamentId is a mandatory param despite it not being part of the path, but part of the body. This choice was made because the other code apis use the tournamentId in the path. Riot's inconsistancy forced my hand here. Here are the method signatures so you can be clear what can be called. Anything in "params" is part of the body or query params. See Riot's official API doc for these values.
|
|
68
|
+
```ruby
|
|
69
|
+
generate_code(tournament_id, params) # Example params: { teamSize: 5, spectatorType: :ALL, pickType: :BLIND_PICK, mapType: :SUMMONERS_RIFT, count: 5 }
|
|
70
|
+
get_code_info(tournament_code)
|
|
71
|
+
update_code_info(tournament_code, params) # Similar params to generate_code. See Riot API for possible params
|
|
72
|
+
get_lobby_events(tournament_code)
|
|
73
|
+
create_provider(params) # Example params: { url: 'http://www.test.com/riot_response_handler' }. you can pass region, but it will default to your client's region if you dont
|
|
74
|
+
create_tournament(params) # Example params: { name: 'MyTournament', providerId: 000 }
|
|
75
|
+
```
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require 'RitoPlz/API/base'
|
|
2
|
+
require 'RitoPlz/API/request'
|
|
3
|
+
|
|
4
|
+
module RitoPlz
|
|
5
|
+
module API
|
|
6
|
+
class Champion < Base
|
|
7
|
+
def initialize(region)
|
|
8
|
+
@region = region
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def all(query_params = {})
|
|
12
|
+
request = Request.new(@region, api_path)
|
|
13
|
+
request.get(query_params)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def by_id(id)
|
|
17
|
+
request = Request.new(@region, api_path("/#{id}"))
|
|
18
|
+
request.get
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
protected
|
|
22
|
+
|
|
23
|
+
def api_path(additional_path = "")
|
|
24
|
+
"/api/lol/#{@region}/v1.2/champion" + additional_path
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
require 'RitoPlz/API/base'
|
|
2
|
+
require 'RitoPlz/API/request'
|
|
3
|
+
|
|
4
|
+
module RitoPlz
|
|
5
|
+
module API
|
|
6
|
+
class ChampionMastery < Base
|
|
7
|
+
def initialize(region, player_id)
|
|
8
|
+
@region = region
|
|
9
|
+
@player_id = player_id
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def all_champions
|
|
13
|
+
request = Request.new(@region, api_path("/champions"))
|
|
14
|
+
request.get
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def by_champion_id(champion_id)
|
|
18
|
+
request = Request.new(@region, api_path("/champion/#{champion_id}"))
|
|
19
|
+
request.get
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def score
|
|
23
|
+
request = Request.new(@region, api_path("/score"))
|
|
24
|
+
request.get
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def top(query_params = {})
|
|
28
|
+
request = Request.new(@region, api_path("/topchampions"))
|
|
29
|
+
request.get(query_params)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
protected
|
|
33
|
+
|
|
34
|
+
def platform
|
|
35
|
+
RitoPlz.to_platform(@region)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def api_path(additional_path = "")
|
|
39
|
+
"/championmastery/location/#{platform}/player/#{@player_id}" + additional_path
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
require 'RitoPlz/API/base'
|
|
2
|
+
require 'RitoPlz/API/request'
|
|
3
|
+
|
|
4
|
+
module RitoPlz
|
|
5
|
+
module API
|
|
6
|
+
class CurrentGame < Base
|
|
7
|
+
def initialize(region)
|
|
8
|
+
@region = region
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def by_player_id(player_id)
|
|
12
|
+
request = Request.new(@region, api_path("/#{player_id}"))
|
|
13
|
+
request.get
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
protected
|
|
17
|
+
|
|
18
|
+
def platform
|
|
19
|
+
RitoPlz.to_platform(@region)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def api_path(additional_path = "")
|
|
23
|
+
"/observer-mode/rest/consumer/getSpectatorGameInfo/#{platform}" + additional_path
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
module RitoPlz
|
|
2
|
+
module API
|
|
3
|
+
class BadRequestException < StandardError
|
|
4
|
+
def initialize
|
|
5
|
+
msg = %{
|
|
6
|
+
400 (BAD REQUEST)
|
|
7
|
+
This error indicates that there is a syntax error in the request and the request has therefore been denied. The client should not continue to make similar requests without modifying the syntax or the requests being made.
|
|
8
|
+
|
|
9
|
+
Common Reasons:
|
|
10
|
+
> A provided parameter was in the wrong format
|
|
11
|
+
> A required parameter was not provided
|
|
12
|
+
|
|
13
|
+
This one is likely our fault, file a bug report
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
super(msg)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
class UnauthorizedException < StandardError
|
|
21
|
+
def initialize
|
|
22
|
+
msg = %{
|
|
23
|
+
401 (UNAUTHORIZED)
|
|
24
|
+
This error indicates that your api key was not authorized for the request you tried to make
|
|
25
|
+
|
|
26
|
+
Common Reason:
|
|
27
|
+
> Make sure you configured your api key before making the request
|
|
28
|
+
> Make sure you entered your api key correctly when you configured
|
|
29
|
+
> Make sure your api key has access to the request you want to make
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
super(msg)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
class ForbiddenException < StandardError
|
|
37
|
+
def initialize
|
|
38
|
+
msg = %{
|
|
39
|
+
403 (FORBIDDEN)
|
|
40
|
+
This error indicates that you are forbidden to access this request
|
|
41
|
+
|
|
42
|
+
Common Reason:
|
|
43
|
+
> Make sure you configured your api key before making the request
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
super(msg)
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
class NotFoundException < StandardError
|
|
51
|
+
def initialize
|
|
52
|
+
msg = %{
|
|
53
|
+
404 (NOT FOUND)
|
|
54
|
+
This error indicates that the server failed to recognize your api request
|
|
55
|
+
|
|
56
|
+
Common Reason:
|
|
57
|
+
> You're looking for an ID that doesn't exist
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
super(msg)
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
class UnsupportedMediaTypeException < StandardError
|
|
65
|
+
def initialize
|
|
66
|
+
msg = %{
|
|
67
|
+
415 (UNSUPPORTED MEDIA TYPE)
|
|
68
|
+
This error indicates that the body of the request was not in a recognizable format
|
|
69
|
+
|
|
70
|
+
Common Reason:
|
|
71
|
+
> We fucked up
|
|
72
|
+
> You're trying to modify our code and you fucked up
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
super(msg)
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
class RateLimitExceededException < StandardError
|
|
80
|
+
def initialize
|
|
81
|
+
msg = %{
|
|
82
|
+
429 (RATE LIMIT EXCEEDED)
|
|
83
|
+
This error indicates you've went over your rate limit. Check your api access rates on Riot's API page.
|
|
84
|
+
|
|
85
|
+
Common Reason:
|
|
86
|
+
> Calm down there big boy, easy on the requests
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
super(msg)
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
class InternalServerException < StandardError
|
|
94
|
+
def initialize
|
|
95
|
+
msg = %{
|
|
96
|
+
500 (INTERNAL SERVER ERROR)
|
|
97
|
+
This error indicates that Riot fucked up. This one's my favorite.
|
|
98
|
+
|
|
99
|
+
Common Reason:
|
|
100
|
+
> Spaghetti code
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
super(msg)
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
class ServiceUnavailableException < StandardError
|
|
108
|
+
def initialize
|
|
109
|
+
msg = %{
|
|
110
|
+
503 (SERVICE UNAVAILABLE)
|
|
111
|
+
This error indicates that Riot's server is unavailable
|
|
112
|
+
|
|
113
|
+
Common Reason:
|
|
114
|
+
> You live in EUW
|
|
115
|
+
> r/dota launched a mass ddos attack
|
|
116
|
+
> Dyrus tried to use the microwave in the server room
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
super(msg)
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
end
|