Class: Clashinator::Client

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#headersObject (readonly)

Returns the value of attribute headers.



6
7
8
# File 'lib/clashinator/client.rb', line 6

def headers
  @headers
end

#tokenObject (readonly)

Returns the value of attribute token.



6
7
8
# File 'lib/clashinator/client.rb', line 6

def token
  @token
end

#uriObject (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, options = {})
  Clashinator::Clan.clan_war_log(@conn, tag, options)
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, options = {})
  Clashinator::League.league_season_rankings(
    @conn, league_id, season_id, options
  )
end

#league_seasons(league_id, options = {}) ⇒ Object



69
70
71
# File 'lib/clashinator/client.rb', line 69

def league_seasons(league_id, options = {})
  Clashinator::League.league_seasons(@conn, league_id, options)
end

#list_clan_members(tag, options = {}) ⇒ Object



29
30
31
# File 'lib/clashinator/client.rb', line 29

def list_clan_members(tag, options = {})
  Clashinator::Clan.list_clan_members(@conn, tag, options)
end

#list_leagues(options = {}) ⇒ Object

league class methods



61
62
63
# File 'lib/clashinator/client.rb', line 61

def list_leagues(options = {})
  Clashinator::League.list_leagues(@conn, options)
end

#list_locations(options = {}) ⇒ Object

location class methods



39
40
41
# File 'lib/clashinator/client.rb', line 39

def list_locations(options = {})
  Clashinator::Location.list_locations(@conn, options)
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, options = {})
  Clashinator::Locaton.location_clan_rankings(
    @conn, location_id, options
  )
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, options = {})
  Clashinator::Location.location_player_rankings(
    @conn, player_tag, options
  )
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(options)
  Clashinator::Clan.search_clans(@conn, options)
end