class Luchadeer::Client
Constants
- GIANT_BOMB
Attributes
api_key[RW]
Public Class Methods
new(opts = {}) { |self| ... }
click to toggle source
# File lib/luchadeer/client.rb, line 18 def initialize(opts = {}) @api_key = opts[:api_key] if opts[:api_key] yield self if block_given? end
Public Instance Methods
get(path, params = {})
click to toggle source
# File lib/luchadeer/client.rb, line 23 def get(path, params = {}) request(:get, path, params) end
Private Instance Methods
connection()
click to toggle source
# File lib/luchadeer/client.rb, line 29 def connection @_connection ||= Faraday.new(GIANT_BOMB, headers: headers) do |f| f.response :parse_api_error f.response :parse_json f.response :parse_http_error f.response :follow_redirects f.adapter :net_http end end
default_params()
click to toggle source
# File lib/luchadeer/client.rb, line 50 def default_params { format: 'json', api_key: api_key } end
headers()
click to toggle source
# File lib/luchadeer/client.rb, line 40 def headers { accept: 'application/json', user_agent: "Luchadeer v#{Luchadeer::VERSION}" } end
request(method, path, params = {})
click to toggle source
# File lib/luchadeer/client.rb, line 44 def request(method, path, params = {}) connection.send(method.to_sym, path, params.merge(default_params)) rescue Faraday::Error => e raise Luchadeer::Error.new e end