Method: InklingApi::Connection#connection

Defined in:
lib/inkling_api.rb

#connectionObject



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/inkling_api.rb', line 43

def connection
  raise "set_url first" unless @url
  @connection ||= begin
    conn = Faraday.new(@url) do |b|
      b.use Faraday::Request::UrlEncoded
      b.use FaradayStack::ResponseJSON, content_type: 'application/json'
      b.use FaradayMiddlewares::ResponseXMLToHash, content_type: 'application/xml'
      b.use PreserveRawBody
      #b.use FaradayStack::Caching, cache, strip_params: %w[access_token client_id] unless cache.nil?
      #b.response :raise_error
      #b.use Faraday::Response::Logger
      b.use FaradayStack::Instrumentation
      b.adapter Faraday.default_adapter
      b.use Mashify
    end

    conn.basic_auth(@login, @password)

    conn
  end
end