Class: Lolxin::Api

Inherits:
Object
  • Object
show all
Defined in:
lib/lolxin/helpers/api.rb

Constant Summary collapse

BASE_ENDPOINT =
"https://%{region}.api.riotgames.com/lol/"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Api

Returns a new instance of Api.



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/lolxin/helpers/api.rb', line 7

def initialize(options = {})
  @api_key = options[:api_key]
  @region  = options[:region]
  @version = options[:version]
  endpoint = BASE_ENDPOINT % {region: region}

  @conn = Faraday.new(endpoint, options[:conn_options]) do |faraday|
    faraday.request(:url_encoded)
    faraday.adapter(Faraday.default_adapter)
    faraday.params[:api_key] = api_key
  end
end

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



5
6
7
# File 'lib/lolxin/helpers/api.rb', line 5

def api_key
  @api_key
end

#connObject

Returns the value of attribute conn.



5
6
7
# File 'lib/lolxin/helpers/api.rb', line 5

def conn
  @conn
end

#regionObject

Returns the value of attribute region.



5
6
7
# File 'lib/lolxin/helpers/api.rb', line 5

def region
  @region
end

#versionObject

Returns the value of attribute version.



5
6
7
# File 'lib/lolxin/helpers/api.rb', line 5

def version
  @version
end