Module: Besepa::Utils::Connection

Included in:
Resource, Resource
Defined in:
lib/besepa/utils/connection.rb

Instance Method Summary collapse

Instance Method Details

#connection(options = {}) ⇒ Faraday::Connection

Returns a Faraday::Connection object

Parameters:

  • options (Hash) (defaults to: {})

    A hash of options

Returns:

  • (Faraday::Connection)


14
15
16
17
18
19
20
21
22
# File 'lib/besepa/utils/connection.rb', line 14

def connection(options={})
  options = options.merge(Besepa.options)
  Faraday.new ( options[:endpoint] ) do |conn|
    conn.request :json
    conn.response :json, :content_type => /\bjson$/
    conn.authorization( 'Bearer', options[:api_key])
    conn.adapter :net_http
  end
end