Module: Carriots::Connection

Included in:
Client
Defined in:
lib/carriots/connection.rb

Overview

Connecction options for Client

Instance Method Summary collapse

Instance Method Details

#connectionObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/carriots/connection.rb', line 8

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

#get(path, params = nil) ⇒ Object



25
26
27
28
29
# File 'lib/carriots/connection.rb', line 25

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