Sha256: a7e3ee40ed507bf23701f2c1f3f903be904d6393a036a62a50556ea4119e12ea

Contents?: true

Size: 666 Bytes

Versions: 4

Compression:

Stored size: 666 Bytes

Contents

require 'faraday_middleware'
require_relative 'faraday_middleware/raise_error'

class Signaling::Api
  attr_reader :connection

  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
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
signaling-1.1.2 lib/signaling/api.rb
signaling-1.1.1 lib/signaling/api.rb
signaling-1.1.0 lib/signaling/api.rb
signaling-1.0.0 lib/signaling/api.rb