Sha256: 3d130ceebfbbfd27af4787f845d19dc18c0c5093f2863f7db653059d22514e40

Contents?: true

Size: 692 Bytes

Versions: 1

Compression:

Stored size: 692 Bytes

Contents

# connection.rb
require 'faraday_middleware'

module Carriots
  # Connecction options for {Client}
  #
  module Connection
    def connection
      @connection ||= begin

        conn = Faraday.new(api_endpoint, connection_options) do |b|
          b.request  :json
          b.response :json, content_type: /\bjson$/
          b.use FaradayMiddleware::FollowRedirects

          # b.use :instrumentation
          b.adapter Faraday.default_adapter
        end
        conn.headers['carriots.apiKey'] = write_api_key

        conn
      end
    end

    def get(path, params = nil)
      connection.get(path) do |request|
        request.params = params if params
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
carriots-0.0.2 lib/carriots/connection.rb