Sha256: 625c452e8b206cf9ea8ce4f082e3e8f35a4c4e248a86bd38945cddab2bcac00a

Contents?: true

Size: 1.97 KB

Versions: 6

Compression:

Stored size: 1.97 KB

Contents

module Lol
  class LeagueRequest < Request
    # Returns the supported API Version
    # @return [String] the supported api version
    def self.api_version
      "v2.5"
    end

    # Retrieves leagues data for summoner, including leagues for all of summoner's teams
    # @param [Array<String>]
    # @return Hash{String => Array<League>}
    def get(*summoner_ids)
      perform_league_request("league/by-summoner/#{summoner_ids.join(",")}")
    end

    # Retrieves leagues entry data for summoner, including league entries for all of summoner's teams
    # @param [Array<String>]
    # @return Hash{String => Array<League>}
    # TODO: Change name to entries?
    def get_entries(*summoner_ids)
      perform_league_request("league/by-summoner/#{summoner_ids.join(',')}/entry")
    end

    # Retrieves leagues data for team
    # @param [Array<String>]
    # @return Hash{String => Array<League>}
    def by_team(*team_ids)
      perform_league_request("league/by-team/#{team_ids.join(',')}")
    end

    # Retrieves leagues entry data for team
    # @param [Array<String>]
    # @return Hash{String => Array<League>}
    # TODO: Change name to?
    def entries_by_team(*team_ids)
      perform_league_request("league/by-team/#{team_ids.join(',')}/entry")
    end

    # Retrieves challenger tier leagues
    # @param [String] game queue type
    # @return [League]
    def challenger(game_queue_type="RANKED_SOLO_5x5")
      league_json = perform_request(api_url('league/challenger', { :type => game_queue_type }))
      League.new(league_json)
    end

    def master(game_queue_type="RANKED_SOLO_5x5")
      league_json = perform_request(api_url('league/master', { :type => game_queue_type }))
      League.new(league_json)
    end

  private

    def perform_league_request(partial_url)
      url = api_url(partial_url)
      perform_request(url).each_with_object({}) do |(summoner_id, leagues), entries_hash|
        entries_hash[summoner_id] = leagues.map(&League.method(:new))
      end
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ruby-lol-0.12.2 lib/lol/league_request.rb
ruby-lol-0.12.1 lib/lol/league_request.rb
ruby-lol-0.12.0 lib/lol/league_request.rb
ruby-lol-0.11.6 lib/lol/league_request.rb
ruby-lol-0.11.5 lib/lol/league_request.rb
ruby-lol-0.11.4 lib/lol/league_request.rb