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
# 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

#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



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

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



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

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

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



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

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

#list_leagues(options = {}) ⇒ Object

league class methods



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

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

#list_locations(options = {}) ⇒ Object

location class methods



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

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