Class: Lol::TournamentRequest
- 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
-
#all_lobby_events(tournament_code:) ⇒ Array<DynamicModel>
Gets a list of lobby events by tournament code.
-
#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.
-
#create_provider(url:) ⇒ Integer
Creates a tournament provider and returns its ID.
-
#create_tournament(provider_id:, name: nil) ⇒ Integer
Creates a tournament and returns its ID.
-
#find_code(tournament_code) ⇒ DynamicModel
Returns the tournament code details.
-
#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.
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
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.
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.
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.
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
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.
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 |