Class: Clashinator::Client
- Inherits:
-
Object
- Object
- Clashinator::Client
- Defined in:
- lib/clashinator/client.rb
Overview
Client class that acts as interface of http methods available for the client itself
Instance Attribute Summary collapse
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
- #clan_info(tag) ⇒ Object
- #clan_war_log(tag, options = {}) ⇒ Object
-
#initialize(token) ⇒ Client
constructor
A new instance of Client.
- #league_info(league_id) ⇒ Object
- #league_season_rankings(league_id, season_id, options = {}) ⇒ Object
- #league_seasons(league_id, options = {}) ⇒ Object
- #list_clan_members(tag, options = {}) ⇒ Object
-
#list_leagues(options = {}) ⇒ Object
league class methods.
-
#list_locations(options = {}) ⇒ Object
location class methods.
- #location_clan_rankings(location_id, options = {}) ⇒ Object
- #location_info(location_id) ⇒ Object
- #location_player_rankings(player_tag, options = {}) ⇒ Object
-
#player_info(tag) ⇒ Object
player class methods.
-
#search_clans(options) ⇒ Object
client class methods.
Constructor Details
#initialize(token) ⇒ Client
Returns a new instance of Client.
8 9 10 11 12 13 14 15 16 |
# File 'lib/clashinator/client.rb', line 8 def initialize(token) @token = token @uri = 'https://api.clashofclans.com' @headers = { 'Authorization' => "Bearer #{@token}" } @conn = Faraday.new( url: @uri, headers: @headers ) end |
Instance Attribute Details
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
6 7 8 |
# File 'lib/clashinator/client.rb', line 6 def headers @headers end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
6 7 8 |
# File 'lib/clashinator/client.rb', line 6 def token @token end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
6 7 8 |
# File 'lib/clashinator/client.rb', line 6 def uri @uri end |
Instance Method Details
#clan_info(tag) ⇒ Object
24 25 26 |
# File 'lib/clashinator/client.rb', line 24 def clan_info(tag) Clashinator::Clan.clan_info(@conn, tag) end |
#clan_war_log(tag, options = {}) ⇒ Object
32 33 34 |
# File 'lib/clashinator/client.rb', line 32 def clan_war_log(tag, = {}) Clashinator::Clan.clan_war_log(@conn, tag, ) end |
#league_info(league_id) ⇒ Object
64 65 66 |
# File 'lib/clashinator/client.rb', line 64 def league_info(league_id) Clashinator::League.league_info(@conn, league_id) end |
#league_season_rankings(league_id, season_id, options = {}) ⇒ Object
72 73 74 75 76 |
# File 'lib/clashinator/client.rb', line 72 def league_season_rankings(league_id, season_id, = {}) Clashinator::League.league_season_rankings( @conn, league_id, season_id, ) end |
#league_seasons(league_id, options = {}) ⇒ Object
68 69 70 |
# File 'lib/clashinator/client.rb', line 68 def league_seasons(league_id, = {}) Clashinator::League.league_seasons(@conn, league_id, ) end |
#list_clan_members(tag, options = {}) ⇒ Object
28 29 30 |
# File 'lib/clashinator/client.rb', line 28 def list_clan_members(tag, = {}) Clashinator::Clan.list_clan_members(@conn, tag, ) end |
#list_leagues(options = {}) ⇒ Object
league class methods
60 61 62 |
# File 'lib/clashinator/client.rb', line 60 def list_leagues( = {}) Clashinator::League.list_leagues(@conn, ) end |
#list_locations(options = {}) ⇒ Object
location class methods
38 39 40 |
# File 'lib/clashinator/client.rb', line 38 def list_locations( = {}) Clashinator::Location.list_locations(@conn, ) end |
#location_clan_rankings(location_id, options = {}) ⇒ Object
46 47 48 49 50 |
# File 'lib/clashinator/client.rb', line 46 def location_clan_rankings(location_id, = {}) Clashinator::Location.location_clan_rankings( @conn, location_id, ) end |
#location_info(location_id) ⇒ Object
42 43 44 |
# File 'lib/clashinator/client.rb', line 42 def location_info(location_id) Clashinator::Location.location_info(@conn, location_id) end |
#location_player_rankings(player_tag, options = {}) ⇒ Object
52 53 54 55 56 |
# File 'lib/clashinator/client.rb', line 52 def location_player_rankings(player_tag, = {}) Clashinator::Location.location_player_rankings( @conn, player_tag, ) end |
#player_info(tag) ⇒ Object
player class methods
80 81 82 |
# File 'lib/clashinator/client.rb', line 80 def player_info(tag) Clashinator::Player.player_info(@conn, tag) end |
#search_clans(options) ⇒ Object
client class methods
20 21 22 |
# File 'lib/clashinator/client.rb', line 20 def search_clans() Clashinator::Clan.search_clans(@conn, ) end |