Module: Ronnie::Connection

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

Instance Method Summary collapse

Instance Method Details

#connectObject



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

def connect
  credentials = authorized? ? authorize : authenticate
  
  connection ||= Faraday.new url: api_endpoint do |builder|
    builder.use Faraday::Request::OAuth, credentials
    
    builder.use Faraday::Request::UrlEncoded

    builder.use Faraday::Response::Mashify 
    builder.use Faraday::Response::ParseJson
    
    builder.adapter Faraday.default_adapter
  end

  connection
end