Sha256: ba9514b3de484ad227c6e6f3aaf2e037757c1cfd5f9a75ae9830e0d505fff428

Contents?: true

Size: 706 Bytes

Versions: 1

Compression:

Stored size: 706 Bytes

Contents

module Lolxin
  class Champion
    BASE_ENDPOINT = "https://%s.api.pvp.net/api/lol/%s/%s/champion"

    attr_accessor :conn

    def initialize(options = {})
      region   = options[:region]
      version  = options[:version]
      api_key  = options[:api_key]
      endpoint = BASE_ENDPOINT % [region, region, version]
      @conn    = Faraday.new(endpoint, options[:conn_options]) do |faraday|
        faraday.request(:url_encoded)
        faraday.response(:logger)
        faraday.adapter(Faraday.default_adapter)
        faraday.params[:api_key] = api_key
      end
    end

    def champion(params = {}, &block)
      id = params.delete(:id).to_s
      conn.get(id, params, &block)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lolxin-0.12.1 lib/lolxin/champion.rb