module Fcoin::Connection

Private Instance Methods

connection() click to toggle source

@private

To establish a connection using the faraday

# File lib/fcoin/connection.rb, line 12
def connection
  options = {
    :headers => { 'Accept' => 'application/json; charset=utf-8', 'User-Agent' => user_agent, 'Content-Type' => 'application/json' },
    :proxy => proxy,
    :url => endpoint,
    :ssl => { :ca_path => ca_path, :ca_file => ca_file }
  }

  Faraday::Connection.new(options) do |conn|
    Array(middlewares).each do |middleware|
      conn.request middleware
    end
    conn.request :multipart
    conn.request :url_encoded
    conn.request :json

    conn.response :fcoin_formatter
    conn.adapter(adapter)
  end
end