Class: VaingloryAPI::Client
- Inherits:
-
Object
- Object
- VaingloryAPI::Client
- Defined in:
- lib/vainglory_api/client.rb
Overview
Used to interface with the official Vainglory API
Constant Summary collapse
- BASE_URL =
The base URL used for most requests
'https://api.dc01.gamelockerapp.com'.freeze
Instance Method Summary collapse
-
#initialize(api_key, region = 'na') ⇒ Client
constructor
A new instance of Client.
-
#link(_link_id) ⇒ Object
Checks to see if a link object exists for a given code.
-
#match(match_id) ⇒ OpenStruct
Gets data for a single match.
-
#matches(filter_params = {}) ⇒ OpenStruct
Gets data from matches (multiple).
-
#player(player_id) ⇒ OpenStruct
Gets data for a single player.
-
#players(player_name, *additional_player_names) ⇒ OpenStruct
Gets data about players (one or more).
-
#samples(filter_params = {}) ⇒ OpenStruct
Gets batches of random match data.
-
#status ⇒ OpenStruct
Gets current API version and release date.
-
#team(_team_id) ⇒ Object
Gets aggregated lifetime information about a single team.
-
#teams(_filter_params = {}) ⇒ Object
Gets aggregated lifetime information about teams (multiple).
-
#telemetry(url) ⇒ OpenStruct
Gets telemtry data from a specified URL.
Constructor Details
#initialize(api_key, region = 'na') ⇒ Client
Requires a valid region short name.
A new instance of Client.
26 27 28 29 30 31 |
# File 'lib/vainglory_api/client.rb', line 26 def initialize(api_key, region = 'na') @api_key = api_key @region = region validate_region end |
Instance Method Details
#link(_link_id) ⇒ Object
Checks to see if a link object exists for a given code
159 160 161 |
# File 'lib/vainglory_api/client.rb', line 159 def link(_link_id) raise(NotImplementedError, 'Coming soon!') end |
#match(match_id) ⇒ OpenStruct
Gets data for a single match
90 91 92 |
# File 'lib/vainglory_api/client.rb', line 90 def match(match_id) get_request(endpoint_uri("shards/#{@region}/matches/#{match_id}")) end |
#matches(filter_params = {}) ⇒ OpenStruct
Gets data from matches (multiple)
76 77 78 |
# File 'lib/vainglory_api/client.rb', line 76 def matches(filter_params = {}) get_request(endpoint_uri("shards/#{@region}/matches", filter_params)) end |
#player(player_id) ⇒ OpenStruct
Gets data for a single player
120 121 122 |
# File 'lib/vainglory_api/client.rb', line 120 def player(player_id) get_request(endpoint_uri("shards/#{@region}/players/#{player_id}")) end |
#players(player_name, *additional_player_names) ⇒ OpenStruct
Gets data about players (one or more)
106 107 108 109 110 |
# File 'lib/vainglory_api/client.rb', line 106 def players(player_name, *additional_player_names) player_names = [player_name].concat(additional_player_names) filter_params = { 'filter[playerNames]' => player_names.join(',') } get_request(endpoint_uri("shards/#{@region}/players", filter_params)) end |
#samples(filter_params = {}) ⇒ OpenStruct
Gets batches of random match data
48 49 50 |
# File 'lib/vainglory_api/client.rb', line 48 def samples(filter_params = {}) get_request(endpoint_uri("shards/#{@region}/samples", filter_params)) end |
#status ⇒ OpenStruct
Gets current API version and release date
170 171 172 |
# File 'lib/vainglory_api/client.rb', line 170 def status get_request_without_headers(endpoint_uri('status')) end |
#team(_team_id) ⇒ Object
Gets aggregated lifetime information about a single team
151 152 153 |
# File 'lib/vainglory_api/client.rb', line 151 def team(_team_id) raise(NotImplementedError, 'Coming soon!') end |
#teams(_filter_params = {}) ⇒ Object
Gets aggregated lifetime information about teams (multiple)
143 144 145 |
# File 'lib/vainglory_api/client.rb', line 143 def teams(_filter_params = {}) raise(NotImplementedError, 'Coming soon!') end |
#telemetry(url) ⇒ OpenStruct
Gets telemtry data from a specified URL
132 133 134 |
# File 'lib/vainglory_api/client.rb', line 132 def telemetry(url) get_request(URI(url), true, false) end |