Sha256: 561498dc14d6ad3d23766d8b5455d0d18ba1b695088f4f94c832d9736c354890

Contents?: true

Size: 789 Bytes

Versions: 9

Compression:

Stored size: 789 Bytes

Contents

require 'faraday'
require 'faraday_middleware'

class RealSavvy::Connection
  attr_reader :faraday

  def initialize(client:)
    @faraday = ::Faraday.new(client.api_url) do |faraday|
                  faraday.request :json
                  faraday.response :json

                  faraday.response :logger, client.logger if client.logging?
                  faraday.adapter Faraday.default_adapter

                  faraday.headers['Authorization'] = "Bearer #{client.token}"
                  faraday.params['impersonated_user_id'] = client.impersonated_user_id if client.impersonated_user_id
              end
  end

  private

  def delegate(m, *args, &block)
    faraday.send(m, *args, &block)
  end

  def method_missing(m, *args, &block)
    delegate(m, *args, &block)
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
real_savvy-0.0.12 lib/real_savvy/connection.rb
real_savvy-0.0.10 lib/real_savvy/connection.rb
real_savvy-0.0.9 lib/real_savvy/connection.rb
real_savvy-0.0.8 lib/real_savvy/connection.rb
real_savvy-0.0.7 lib/real_savvy/connection.rb
real_savvy-0.0.6 lib/real_savvy/connection.rb
real_savvy-0.0.5 lib/real_savvy/connection.rb
real_savvy-0.0.4 lib/real_savvy/connection.rb
real_savvy-0.0.3 lib/real_savvy/connection.rb