7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/tumblr/connection.rb', line 7
def connection(options={})
options = options.clone
default_options = {
:headers => {
:accept => 'application/json',
:user_agent => "tumblr_client (ruby) - #{Tumblr::VERSION}"
},
:url => "#{api_scheme}://#{api_host}/"
}
client = Faraday.default_adapter
Faraday.new(default_options.merge(options)) do |conn|
data = { :api_host => api_host, :ignore_extra_keys => true}.merge(credentials)
unless credentials.empty?
conn.request :oauth, data
end
conn.request :multipart
conn.request :url_encoded
conn.response :json, :content_type => /\bjson$/
conn.adapter client
end
end
|