module TicketingHub::Connection

Private Instance Methods

connection(options={}) click to toggle source
# File lib/ticketing_hub/connection.rb, line 29
def connection options={}
  token = options.delete(:access_token) || access_token

  options = {
    authenticate: !token.nil?,
    force_urlencoded: false,
    raw: false,
    accept: 'application/json',
    user_agent: user_agent
  }.merge(options)

  options.merge! proxy: proxy unless proxy.nil?

  Faraday.new(options) do |conn|
    conn.request :oauth2, token unless token.nil?
    conn.request options[:force_urlencoded] ? :url_encoded : :json

    conn.use ErrorHandler
    conn.response :follow_redirects
    conn.response :mashify
    conn.response :json, content_type: /\bjson$/
  
    faraday_config_block.call conn if faraday_config_block
    conn.adapter *adapter
  end
end