Module: Flickr::Client::Connection

Included in:
Flickr::Client
Defined in:
lib/flickr/client/connection.rb

Instance Method Summary collapse

Instance Method Details

#adapterObject



28
29
30
# File 'lib/flickr/client/connection.rb', line 28

def adapter
  @adapter || Faraday.default_adapter
end

#connection(options = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/flickr/client/connection.rb', line 9

def connection(options = {})
  @connection = Faraday.new(:url => endpoint(options[:secure])) do |builder|
    builder.use Faraday::Request::OAuth, authentication_options(options)
    builder.use Faraday::Request::Multipart
    builder.use Faraday::Request::UrlEncoded
          
    builder.use Faraday::Response::RaiseFlickrError
    if (options[:format] or format).to_s == 'json'
      builder.use Faraday::Response::ParseJson
    else
      builder.use Faraday::Response::ParseXml
    end        
    builder.use Faraday::Response::RaiseError
    builder.use Faraday::Response::Logger if options[:enable_logging] or enable_logging
  
    builder.adapter adapter
  end
end