Sha256: 927c489b74d53acd5ce6203da5aca9aaf947829bffe731cffe17346400f2f6fe

Contents?: true

Size: 624 Bytes

Versions: 7

Compression:

Stored size: 624 Bytes

Contents

class ShippingEasy::Http::FaradayAdapter

  extend Forwardable

  def_delegators :request, :body, :params, :base_url, :http_method, :uri

  attr_reader :request

  def initialize(request)
    @request = request
  end

  def connect!
    send(http_method)
  end

  def post
    connection.post do |req|
      req.url uri, params
      req.body = request.body
    end
  end

  def get
    connection.get do |req|
      req.url uri, params
      req.body = request.body
    end
  end

  def connection
    @connection ||= Faraday.new(url: base_url) do |faraday|
      faraday.adapter Faraday.default_adapter
    end
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
shipping_easy-0.6.1 lib/shipping_easy/http/faraday_adapter.rb
shipping_easy-0.6.0 lib/shipping_easy/http/faraday_adapter.rb
shipping_easy-0.5.1 lib/shipping_easy/http/faraday_adapter.rb
shipping_easy-0.5.0 lib/shipping_easy/http/faraday_adapter.rb
shipping_easy-0.3.2 lib/shipping_easy/http/faraday_adapter.rb
shipping_easy-0.3.1 lib/shipping_easy/http/faraday_adapter.rb
shipping_easy-0.3.0 lib/shipping_easy/http/faraday_adapter.rb