Class: RiotKit::Clients::Riot

Inherits:
Object
  • Object
show all
Defined in:
lib/riot_kit/clients/riot.rb

Constant Summary collapse

RIOT_JSON =
{ 'Content-Type' => 'application/json' }.freeze

Instance Method Summary collapse

Constructor Details

#initialize(config: RiotKit.config) ⇒ Riot

Returns a new instance of Riot.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/riot_kit/clients/riot.rb', line 13

def initialize(config: RiotKit.config)
  @config = config
  @routing_client = Http::Client.new(
    base_url: config.routing_base_url,
    headers: RIOT_JSON,
    timeout: config.http_timeout,
    logger: config.logger,
    retry_attempts: config.retry_attempts,
    retry_base_delay: config.retry_base_delay
  )
  @platform_client = Http::Client.new(
    base_url: config.platform_base_url,
    headers: RIOT_JSON,
    timeout: config.http_timeout,
    logger: config.logger,
    retry_attempts: config.retry_attempts,
    retry_base_delay: config.retry_base_delay
  )
end

Instance Method Details

#get_account_by_riot_id(game_name:, tag_line:) ⇒ Object



33
34
35
36
37
# File 'lib/riot_kit/clients/riot.rb', line 33

def (game_name:, tag_line:)
  headers = riot_headers
  path = "/riot/account/v1/accounts/by-riot-id/#{encode(game_name)}/#{encode(tag_line)}"
  @routing_client.get(path, headers: headers)
end

#get_match(match_id:) ⇒ Object



49
50
51
52
53
# File 'lib/riot_kit/clients/riot.rb', line 49

def get_match(match_id:)
  headers = riot_headers
  path = "/lol/match/v5/matches/#{encode(match_id)}"
  @routing_client.get(path, headers: headers)
end

#get_match_ids_by_puuid(puuid:, queue: nil, count: 100, start_time: nil, end_time: nil) ⇒ Object



39
40
41
42
43
44
45
46
47
# File 'lib/riot_kit/clients/riot.rb', line 39

def get_match_ids_by_puuid(puuid:, queue: nil, count: 100, start_time: nil, end_time: nil)
  headers = riot_headers
  query = { start: 0, count: count }
  query[:queue] = queue if queue
  query[:startTime] = start_time if start_time
  query[:endTime] = end_time if end_time
  path = "/lol/match/v5/matches/by-puuid/#{encode(puuid)}/ids"
  @routing_client.get(path, query: query, headers: headers)
end

#get_ranked_entries_by_puuid(puuid:) ⇒ Object



55
56
57
58
59
# File 'lib/riot_kit/clients/riot.rb', line 55

def get_ranked_entries_by_puuid(puuid:)
  headers = riot_headers
  path = "/lol/league/v4/entries/by-puuid/#{encode(puuid)}"
  @platform_client.get(path, headers: headers)
end