Class: Lol::TournamentRequest

Inherits:
Request
  • Object
show all
Defined in:
lib/lol/tournament_request.rb

Instance Attribute Summary

Attributes inherited from Request

#api_key, #cache_store, #rate_limiter, #region

Instance Method Summary collapse

Methods inherited from Request

#api_query_string, #api_url, #api_version, api_version, #cached?, #clean_url, #initialize, #perform_rate_limited_request, #perform_request, #perform_uncached_request, #platform, platforms, #store, #ttl

Constructor Details

This class inherits a constructor from Lol::Request

Instance Method Details

#all_lobby_events(tournament_code:) ⇒ Array<DynamicModel>

Gets a list of lobby events by tournament code

Parameters:

  • tournament_code (String)

    the tournament code string

Returns:



89
90
91
92
# 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

#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") ⇒ Array<String>

Create a tournament code for the given tournament.

Parameters:

  • count (Integer) (defaults to: nil)

    The number of codes to create (max 1000)

  • tournament_id (Integer)

    The tournament ID

  • spectator_type (String) (defaults to: "ALL")

    The spectator type of the game. Valid values are NONE, LOBBYONLY, ALL.

  • team_size (Integer) (defaults to: 5)

    The team size of the game. Valid values are 1-5.

  • pick_type (String) (defaults to: "TOURNAMENT_DRAFT")

    The pick type of the game. Valid values are BLIND_PICK, DRAFT_MODE, ALL_RANDOM, TOURNAMENT_DRAFT.

  • map_type (String) (defaults to: "SUMMONERS_RIFT")

    The map type of the game. Valid values are SUMMONERS_RIFT, TWISTED_TREELINE, CRYSTAL_SCAR, and HOWLING_ABYSS.

  • allowed_participants (Array<Integer>) (defaults to: nil)

    List of participants in order to validate the players eligible to join the lobby.

  • metadata (String) (defaults to: nil)

    Optional string that may contain any data in any format, if specified at all. Used to denote any custom information about the game.

Returns:

  • (Array<String>)

    generated tournament codes



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# 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"           => ,
    "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:) ⇒ Integer

Creates a tournament provider and returns its ID.

Parameters:

  • url (String)

    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

Returns:

  • (Integer)

    Provider ID



16
17
18
19
20
21
22
# 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) ⇒ Integer

Creates a tournament and returns its ID.

Parameters:

  • provider_id (Integer)

    The provider ID to specify the regional registered provider data to associate this tournament.

  • name (String) (defaults to: nil)

    Name of the tournament

Returns:

  • (Integer)

    Tournament ID



28
29
30
31
32
33
# 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) ⇒ DynamicModel

Returns the tournament code details

Parameters:

  • tournament_code (String)

    the tournament code string

Returns:



82
83
84
# 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) ⇒ Object

Update the pick type, map, spectator type, or allowed summoners for a code.

Parameters:

  • tournament_code (String)

    The tournament code to update

  • allowed_participants (Array<Integer>) (defaults to: nil)

    List of participants in order to validate the players eligible to join the lobby.

  • map_type (String) (defaults to: nil)

    The map type of the game. Valid values are SUMMONERS_RIFT, TWISTED_TREELINE, CRYSTAL_SCAR, and HOWLING_ABYSS.

  • pick_type (String) (defaults to: nil)

    The pick type of the game. Valid values are BLIND_PICK, DRAFT_MODE, ALL_RANDOM, TOURNAMENT_DRAFT.

  • spectator_type (String) (defaults to: nil)

    The spectator type of the game. Valid values are NONE, LOBBYONLY, ALL.



69
70
71
72
73
74
75
76
77
# 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