Method: ExternalServices::Api#connection

Defined in:
lib/external_services/api.rb

#connectionObject



53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/external_services/api.rb', line 53

def connection
  return if api_url.blank?

  @connection ||= Faraday.new(url: api_url) do |f|
    f.request  :json
    f.response :json

    f.adapter  :net_http

    f.headers['Content-Type'] = 'application/json'
    f.headers['Accept']       = 'application/json'
    f.headers[auth_header]    = api_key
  end
end