Upgrade to Faraday 0.9 (fixes params encoding problems)

This commit is contained in:
Steven Bazyl committed 2013-05-13 14:03:49 -07:00
1 parent 9cd5601134
commit 794c6a90f7
11 files changed
+53 -49

No files matched your search

+14 -2
View File
@@ -107,7 +107,12 @@ module Google
@discovery_uris = {}
@discovery_documents = {}
@discovered_apis = {}
self.connection = Faraday.new do |faraday|
faraday.adapter Faraday.default_adapter
faraday.options.params_encoder = Faraday::FlatParamsEncoder
end
return self
end
@@ -167,6 +172,13 @@ module Google
return @authorization
end
##
# Default Faraday/HTTP connection.
#
# @return [Faraday::Connection]
attr_accessor :connection
##
# The setting that controls whether or not the api client attempts to
# refresh authorization when a 401 is hit in #execute.
@@ -557,7 +569,7 @@ module Google
request.parameters['key'] ||= self.key unless self.key.nil?
request.parameters['userIp'] ||= self.user_ip unless self.user_ip.nil?
connection = options[:connection] || Faraday.default_connection
connection = options[:connection] || self.connection
request.authorization = options[:authorization] || self.authorization unless options[:authenticated] == false
result = request.send(connection)
@@ -187,6 +187,7 @@ module Google
# @return [Addressable::URI] The URI after expansion.
def generate_uri(parameters={})
parameters = self.normalize_parameters(parameters)
self.validate_parameters(parameters)
template_variables = self.uri_template.variables
upload_type = parameters.assoc('uploadType') || parameters.assoc('upload_type')
+7 -5
View File
@@ -14,6 +14,8 @@
require 'faraday'
require 'faraday/utils'
require 'faraday/options'
require 'faraday/request/multipart'
require 'multi_json'
require 'compat/multi_json'
require 'addressable/uri'
@@ -71,7 +73,7 @@ module Google
# @option options [String, Symbol] :http_method
# HTTP method when requesting a URI
def initialize(options={})
@parameters = Hash[options[:parameters] || {}]
@parameters = Faraday::Utils::ParamsHash[options[:parameters] || {}]
@headers = Faraday::Utils::Headers.new
self.headers.merge!(options[:headers]) unless options[:headers].nil?
self.api_method = options[:api_method]
@@ -314,10 +316,10 @@ module Google
# @param [String] boundary
# Boundary for separating each part of the message
def build_multipart(parts, mime_type = 'multipart/related', boundary = MULTIPART_BOUNDARY)
env = {
:request_headers => {'Content-Type' => "#{mime_type};boundary=#{boundary}"},
:request => { :boundary => boundary }
}
env = Faraday::Env.new
env.request = Faraday::RequestOptions.new
env.request.boundary = boundary
env.request_headers = {'Content-Type' => "#{mime_type};boundary=#{boundary}"}
multipart = Faraday::Request::Multipart.new
self.body = multipart.create_multipart(env, parts.map {|part| [nil, part]})
self.headers.update(env[:request_headers])
+2 -2
View File
@@ -21,8 +21,8 @@ if !defined?(::Google::APIClient::VERSION)
class APIClient
module VERSION
MAJOR = 0
MINOR = 6
TINY = 3
MINOR = 7
TINY = 0
STRING = [MAJOR, MINOR, TINY].join('.')
end
end