class Lol::TournamentRequest

Public Instance Methods

all_lobby_events(tournament_code: result = perform_request api_url "lobby-events/by-code/ click to toggle source

Gets a list of lobby events by tournament code @param [String] tournament_code the tournament code string @return [Array<DynamicModel>] List of lobby events

# File lib/lol/tournament_request.rb, line 89
def all_lobby_events tournament_code:
  result = perform_request api_url "lobby-events/by-code/#{tournament_code}"
  result["eventList"].map { |e| DynamicModel.new e }
end
api_base_path() click to toggle source

@!visibility private

# File lib/lol/tournament_request.rb, line 4
def api_base_path
  "/lol/tournament/#{self.class.api_version}"
end
api_base_url() click to toggle source

@!visibility private

# File lib/lol/tournament_request.rb, line 9
def api_base_url
  "https://americas.api.riotgames.com"
end
create_codes(tournament_id:, count: nil, allowed_participants: nil, map_type: "SUMMONERS_RIFT", metadata: nil, team_size: 5, pick_type: "TOURNAMENT_DRAFT", spectator_type: "ALL") click to toggle source

Create a tournament code for the given tournament. @param [Integer] count The number of codes to create (max 1000) @param [Integer] tournament_id The tournament ID @param [String] spectator_type The spectator type of the game. Valid values are NONE, LOBBYONLY, ALL. @param [Integer] team_size The team size of the game. Valid values are 1-5. @param [String] pick_type The pick type of the game. Valid values are BLIND_PICK, DRAFT_MODE, ALL_RANDOM, TOURNAMENT_DRAFT. @param [String] map_type The map type of the game. Valid values are SUMMONERS_RIFT, TWISTED_TREELINE, CRYSTAL_SCAR, and HOWLING_ABYSS. @param [Array<Integer>] allowed_participants List of participants in order to validate the players eligible to join the lobby. @param [String] metadata Optional string that may contain any data in any format, if specified at all. Used to denote any custom information about the game. @return [Array<String>] generated tournament codes

# File lib/lol/tournament_request.rb, line 45
def create_codes tournament_id:, count: nil, allowed_participants: nil,
                   map_type: "SUMMONERS_RIFT", metadata: nil, team_size: 5,
                   pick_type: "TOURNAMENT_DRAFT", spectator_type: "ALL"
  body = {
    "allowedSummonerIds" => allowed_participants,
    "mapType"            => map_type,
    "metadata"           => metadata,
    "pickType"           => pick_type,
    "spectatorType"      => spectator_type,
    "teamSize"           => team_size
  }.compact
  uri_params = {
    "tournamentId" => tournament_id,
    "count"        => count
  }.compact
  perform_request api_url("codes", uri_params), :post, body
end
create_provider(url: body = { "url" => url, "region" => region.upcase) click to toggle source

Creates a tournament provider and returns its ID. @param [String] url The provider's callback URL to which tournament game results in this region should be posted. The URL must be well-formed, use the http or https protocol, and use the default port for the protocol @return [Integer] Provider ID

# File lib/lol/tournament_request.rb, line 16
def create_provider url:
  body = {
    "url"    => url,
    "region" => region.upcase
  }
  perform_request api_url("providers"), :post, body
end
create_tournament(provider_id:, name: nil) click to toggle source

Creates a tournament and returns its ID. @param [Integer] provider_id The provider ID to specify the regional registered provider data to associate this tournament. @param [String] name Name of the tournament @return [Integer] Tournament ID

# File lib/lol/tournament_request.rb, line 28
def create_tournament provider_id:, name: nil
  body = { "providerId" => provider_id, "name" => name }.delete_if do |k, v|
     v.nil?
  end
  perform_request api_url("tournaments"), :post, body
end
find_code(tournament_code) click to toggle source

Returns the tournament code details @param [String] tournament_code the tournament code string @return [DynamicModel] A tournament code representation

# File lib/lol/tournament_request.rb, line 82
def find_code tournament_code
  DynamicModel.new perform_request api_url "codes/#{tournament_code}"
end
update_code(tournament_code, allowed_participants: nil, map_type: nil, pick_type: nil, spectator_type: nil) click to toggle source

Update the pick type, map, spectator type, or allowed summoners for a code. @param [String] tournament_code The tournament code to update @param [Array<Integer>] allowed_participants List of participants in order to validate the players eligible to join the lobby. @param [String] map_type The map type of the game. Valid values are SUMMONERS_RIFT, TWISTED_TREELINE, CRYSTAL_SCAR, and HOWLING_ABYSS. @param [String] pick_type The pick type of the game. Valid values are BLIND_PICK, DRAFT_MODE, ALL_RANDOM, TOURNAMENT_DRAFT. @param [String] spectator_type The spectator type of the game. Valid values are NONE, LOBBYONLY, ALL.

# File lib/lol/tournament_request.rb, line 69
def update_code tournament_code, allowed_participants: nil, map_type: nil, pick_type: nil, spectator_type: nil
  body = {
    "allowedSummonerIds" => allowed_participants,
    "mapType"            => map_type,
    "pickType"           => pick_type,
    "spectatorType"      => spectator_type
  }.compact
  perform_request api_url("codes/#{tournament_code}"), :put, body
end