Module: Strife::Default

Defined in:
lib/strife/default.rb

Constant Summary collapse

API_ENDPOINT =
'http://prod.api.pvp.net/api/lol/'.freeze
USER_AGENT =
"Strife Riot API GEM v#{Strife::VERSION}".freeze
MEDIA_TYPE =
'application/json'.freeze
REGION =
'na'.freeze
MIDDLEWARE =
Faraday::Builder.new do |builder|
  builder.use Strife::Response::RaiseError
  builder.use :http_cache, store: :memory_store
  builder.adapter Faraday.default_adapter
end

Class Method Summary collapse

Class Method Details

.api_endpointObject



31
32
33
# File 'lib/strife/default.rb', line 31

def api_endpoint
  ENV['STRIFE_API_ENDPOINT'] || API_ENDPOINT
end

.api_keyObject



27
28
29
# File 'lib/strife/default.rb', line 27

def api_key
  ENV['STRIFE_API_KEY']
end

.connection_optionsObject



47
48
49
50
51
52
53
54
# File 'lib/strife/default.rb', line 47

def connection_options
  {
    headers: {
      accept: default_media_type,
      user_agent: user_agent
    }
  }
end

.default_media_typeObject



39
40
41
# File 'lib/strife/default.rb', line 39

def default_media_type
  ENV['STRIFE_DEFAULT_MEDIA_TYPE'] || MEDIA_TYPE
end

.middlewareObject



43
44
45
# File 'lib/strife/default.rb', line 43

def middleware
  MIDDLEWARE
end

.optionsObject



23
24
25
# File 'lib/strife/default.rb', line 23

def options
  Hash[Strife::Configurable.keys.map {|key| [key, send(key)]}]
end

.regionObject



56
57
58
# File 'lib/strife/default.rb', line 56

def region
  ENV['STRIFE_REGION'] || REGION
end

.user_agentObject



35
36
37
# File 'lib/strife/default.rb', line 35

def user_agent
  ENV['STRIFE_USER_AGENT'] || USER_AGENT
end