class Signaling::Api

Attributes

connection[R]

Public Class Methods

new(options, &block) click to toggle source
# File lib/signaling/api.rb, line 7
def initialize(options, &block)
  @connection = Faraday.new(url: options[:url]) do |conn|
    block.call(conn) if block_given?

    conn.request :multipart
    conn.request :url_encoded

    conn.use Signaling::FaradayMiddleware::RaiseError

    if options[:logger]
      conn.response :logger, options[:logger]
    end

    conn.response :mashify, mash_class: (options[:mash_class])
    conn.response :json, content_type: /\bjson$/

    conn.adapter options[:adapter] || Faraday.default_adapter
  end
end