module PUBG::Connection

Network layer

Public Instance Methods

agent() click to toggle source
# File lib/pubg/connection.rb, line 8
def agent
  @agent || Sawyer::Agent.new(api_endpoint, sawyer_options) do |http|
    http.headers[:accept] = @connection_options[:headers][:accept]
    http.authorization 'Bearer', @access_token
  end
end
get(url, options = {}) click to toggle source
# File lib/pubg/connection.rb, line 4
def get(url, options = {})
  request :get, url, options
end

Private Instance Methods

request(method, path, options = {}) click to toggle source
# File lib/pubg/connection.rb, line 17
def request(method, path, options = {})
  @last_response = response = agent.call(method, Addressable::URI.parse(path.to_s), nil, options)
  response.data
end
sawyer_options() click to toggle source
# File lib/pubg/connection.rb, line 22
def sawyer_options
  {
    links_parser: Sawyer::LinkParsers::Simple.new,
    faraday: Faraday.new(@connection_options)
  }
end