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 17 |
# File 'lib/clashinator/client.rb', line 8 def initialize(token) @token = token file_path = File.join(File.dirname(__FILE__), 'config/config.yml') @uri = YAML.load_file(file_path)['url'] @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
25 26 27 |
# File 'lib/clashinator/client.rb', line 25 def clan_info(tag) Clashinator::Clan.clan_info(@conn, tag) end |
#clan_war_log(tag, options = {}) ⇒ Object
33 34 35 |
# File 'lib/clashinator/client.rb', line 33 def clan_war_log(tag, = {}) Clashinator::Clan.clan_war_log(@conn, tag, ) end |
#league_info(league_id) ⇒ Object
65 66 67 |
# File 'lib/clashinator/client.rb', line 65 def league_info(league_id) Clashinator::League.league_info(@conn, league_id) end |
#league_season_rankings(league_id, season_id, options = {}) ⇒ Object
73 74 75 76 77 |
# File 'lib/clashinator/client.rb', line 73 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
69 70 71 |
# File 'lib/clashinator/client.rb', line 69 def league_seasons(league_id, = {}) Clashinator::League.league_seasons(@conn, league_id, ) end |
#list_clan_members(tag, options = {}) ⇒ Object
29 30 31 |
# File 'lib/clashinator/client.rb', line 29 def list_clan_members(tag, = {}) Clashinator::Clan.list_clan_members(@conn, tag, ) end |
#list_leagues(options = {}) ⇒ Object
league class methods
61 62 63 |
# File 'lib/clashinator/client.rb', line 61 def list_leagues( = {}) Clashinator::League.list_leagues(@conn, ) end |
#list_locations(options = {}) ⇒ Object
location class methods
39 40 41 |
# File 'lib/clashinator/client.rb', line 39 def list_locations( = {}) Clashinator::Location.list_locations(@conn, ) end |
#location_clan_rankings(location_id, options = {}) ⇒ Object
47 48 49 50 51 |
# File 'lib/clashinator/client.rb', line 47 def location_clan_rankings(location_id, = {}) Clashinator::Locaton.location_clan_rankings( @conn, location_id, ) end |
#location_info(location_id) ⇒ Object
43 44 45 |
# File 'lib/clashinator/client.rb', line 43 def location_info(location_id) Clashinator::Location.location_info(@conn, location_id) end |
#location_player_rankings(player_tag, options = {}) ⇒ Object
53 54 55 56 57 |
# File 'lib/clashinator/client.rb', line 53 def location_player_rankings(player_tag, = {}) Clashinator::Location.location_player_rankings( @conn, player_tag, ) end |
#player_info(tag) ⇒ Object
player class methods
81 82 83 |
# File 'lib/clashinator/client.rb', line 81 def player_info(tag) Clashinator::Player.player_info(@conn, tag) end |
#search_clans(options) ⇒ Object
client class methods
21 22 23 |
# File 'lib/clashinator/client.rb', line 21 def search_clans() Clashinator::Clan.search_clans(@conn, ) end |