google-api-client 0.4.4 → 0.4.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,11 @@
1
+ # 0.4.5
2
+
3
+ * Updated Launchy dependency
4
+ * Updated Faraday dependency
5
+ * Updated Addressable dependency
6
+ * Updated Autoparse dependency
7
+ * Removed Sinatra development dependency
8
+
1
9
  # 0.4.4
2
10
 
3
11
  * Added batch execution
data/Gemfile CHANGED
@@ -1,16 +1,18 @@
1
1
  source :rubygems
2
2
 
3
- gem 'signet', '>= 0.3.4'
4
- gem 'addressable', '>= 2.2.3'
3
+ gemspec
4
+
5
+ gem 'signet', '>= 0.4.1'
6
+ gem 'addressable', '>= 2.3.2'
5
7
  gem 'uuidtools', '>= 2.1.0'
6
- gem 'autoparse', '>= 0.3.1'
7
- gem 'faraday', '~> 0.7.0'
8
- gem 'multi_json', '>= 1.3.0'
8
+ gem 'autoparse', '>= 0.3.2'
9
+ gem 'faraday', '~> 0.8.1'
10
+ gem 'multi_json', '>= 1.0.0'
9
11
  gem 'extlib', '>= 0.9.15'
10
12
  gem 'jruby-openssl', :platforms => :jruby
11
13
 
12
14
  group :development do
13
- gem 'launchy'
15
+ gem 'launchy', '>= 2.1.1'
14
16
  gem 'yard'
15
17
  gem 'redcarpet'
16
18
  end
@@ -21,7 +23,7 @@ end
21
23
 
22
24
  group :test, :development do
23
25
  gem 'rake', '>= 0.9.0'
24
- gem 'rspec', '~> 1.2.9'
26
+ gem 'rspec', '>= 2.11.0'
25
27
  gem 'rcov', '>= 0.9.9', :platform => :mri_18
26
28
  end
27
29
 
@@ -1,22 +1,33 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ google-api-client (0.4.5)
5
+ addressable (>= 2.3.2)
6
+ autoparse (>= 0.3.2)
7
+ extlib (>= 0.9.15)
8
+ faraday (~> 0.8.1)
9
+ launchy (>= 2.1.1)
10
+ multi_json (>= 1.0.0)
11
+ signet (>= 0.4.1)
12
+ uuidtools (>= 2.1.0)
13
+
1
14
  GEM
2
15
  remote: http://rubygems.org/
3
16
  specs:
4
- addressable (2.2.8)
5
- autoparse (0.3.1)
6
- addressable (~> 2.2.3)
17
+ addressable (2.3.2)
18
+ autoparse (0.3.2)
19
+ addressable (>= 2.3.1)
7
20
  extlib (>= 0.9.15)
8
21
  multi_json (>= 1.0.0)
22
+ diff-lcs (1.1.3)
9
23
  extlib (0.9.15)
10
- faraday (0.7.6)
11
- addressable (~> 2.2)
24
+ faraday (0.8.1)
12
25
  multipart-post (~> 1.1)
13
- rack (~> 1.1)
14
26
  idn (0.0.2)
15
- json (1.7.3)
16
- jwt (0.1.4)
17
- json (>= 1.2.4)
18
- launchy (2.1.0)
19
- addressable (~> 2.2.6)
27
+ jwt (0.1.5)
28
+ multi_json (>= 1.0)
29
+ launchy (2.1.1)
30
+ addressable (~> 2.3)
20
31
  multi_json (1.3.6)
21
32
  multipart-post (1.1.5)
22
33
  rack (1.4.1)
@@ -25,37 +36,45 @@ GEM
25
36
  rake (0.9.2.2)
26
37
  rcov (1.0.0)
27
38
  redcarpet (2.1.1)
28
- rspec (1.2.9)
29
- signet (0.3.4)
30
- addressable (~> 2.2.3)
31
- faraday (~> 0.7.0)
32
- jwt (>= 0.1.4)
39
+ rspec (2.11.0)
40
+ rspec-core (~> 2.11.0)
41
+ rspec-expectations (~> 2.11.0)
42
+ rspec-mocks (~> 2.11.0)
43
+ rspec-core (2.11.1)
44
+ rspec-expectations (2.11.2)
45
+ diff-lcs (~> 1.1.3)
46
+ rspec-mocks (2.11.1)
47
+ signet (0.4.1)
48
+ addressable (>= 2.2.3)
49
+ faraday (~> 0.8.1)
50
+ jwt (>= 0.1.5)
33
51
  multi_json (>= 1.0.0)
34
52
  sinatra (1.3.2)
35
53
  rack (~> 1.3, >= 1.3.6)
36
54
  rack-protection (~> 1.2)
37
55
  tilt (~> 1.3, >= 1.3.3)
38
56
  tilt (1.3.3)
39
- uuidtools (2.1.2)
40
- yard (0.8.1)
57
+ uuidtools (2.1.3)
58
+ yard (0.8.2.1)
41
59
 
42
60
  PLATFORMS
43
61
  ruby
44
62
 
45
63
  DEPENDENCIES
46
- addressable (>= 2.2.3)
47
- autoparse (>= 0.3.1)
64
+ addressable (>= 2.3.2)
65
+ autoparse (>= 0.3.2)
48
66
  extlib (>= 0.9.15)
49
- faraday (~> 0.7.0)
67
+ faraday (~> 0.8.1)
68
+ google-api-client!
50
69
  idn
51
70
  jruby-openssl
52
- launchy
53
- multi_json (>= 1.3.0)
71
+ launchy (>= 2.1.1)
72
+ multi_json (>= 1.0.0)
54
73
  rake (>= 0.9.0)
55
74
  rcov (>= 0.9.9)
56
75
  redcarpet
57
- rspec (~> 1.2.9)
58
- signet (>= 0.3.4)
76
+ rspec (>= 2.11.0)
77
+ signet (>= 0.4.1)
59
78
  sinatra
60
79
  uuidtools (>= 2.1.0)
61
80
  yard
data/Rakefile CHANGED
@@ -5,15 +5,6 @@ $LOAD_PATH.uniq!
5
5
  require 'rubygems'
6
6
  require 'rake'
7
7
 
8
- gem 'rspec', '~> 1.2.9'
9
- begin
10
- require 'spec/rake/spectask'
11
- rescue LoadError
12
- STDERR.puts "Please install rspec:"
13
- STDERR.puts "sudo gem install rspec"
14
- exit(1)
15
- end
16
-
17
8
  require File.join(File.dirname(__FILE__), 'lib/google/api_client', 'version')
18
9
 
19
10
  PKG_DISPLAY_NAME = 'Google API Client'
@@ -38,7 +29,7 @@ PKG_FILES = FileList[
38
29
  '[A-Z]*', 'Rakefile'
39
30
  ].exclude(/database\.yml/).exclude(/[_\.]git$/)
40
31
 
41
- RCOV_ENABLED = (RUBY_PLATFORM != 'java' && RUBY_VERSION =~ /^1\.8/)
32
+ RCOV_ENABLED = !!(RUBY_PLATFORM != 'java' && RUBY_VERSION =~ /^1\.8/)
42
33
  if RCOV_ENABLED
43
34
  task :default => 'spec:rcov'
44
35
  else
@@ -11,7 +11,7 @@ OAUTH_SERVER_PORT = 12736
11
11
  require 'rubygems'
12
12
  require 'optparse'
13
13
 
14
- gem 'faraday', '~> 0.7.0'
14
+ gem 'faraday', '~> 0.8.1'
15
15
  require 'faraday'
16
16
  require 'faraday/utils'
17
17
 
@@ -187,7 +187,7 @@ HTML
187
187
  end
188
188
 
189
189
  def client
190
- gem 'signet', '~> 0.3.0'
190
+ gem 'signet', '~> 0.4.0'
191
191
  require 'signet/oauth_1/client'
192
192
  require 'yaml'
193
193
  require 'irb'
@@ -281,7 +281,7 @@ HTML
281
281
  ]
282
282
 
283
283
  def oauth_1_login
284
- gem 'signet', '~> 0.3.0'
284
+ gem 'signet', '~> 0.4.0'
285
285
  require 'signet/oauth_1/client'
286
286
  require 'launchy'
287
287
  require 'yaml'
@@ -349,7 +349,7 @@ HTML
349
349
  end
350
350
 
351
351
  def oauth_2_login
352
- gem 'signet', '~> 0.3.0'
352
+ gem 'signet', '~> 0.4.0'
353
353
  require 'signet/oauth_2/client'
354
354
  require 'launchy'
355
355
  require 'yaml'
@@ -13,7 +13,7 @@
13
13
  # limitations under the License.
14
14
 
15
15
 
16
- gem 'faraday', '~> 0.7.0'
16
+ gem 'faraday', '~> 0.8.1'
17
17
  require 'faraday'
18
18
  require 'faraday/utils'
19
19
  require 'multi_json'
@@ -113,7 +113,7 @@ module Google
113
113
  def authorization=(new_authorization)
114
114
  case new_authorization
115
115
  when :oauth_1, :oauth
116
- gem 'signet', '~> 0.3.0'
116
+ gem 'signet', '~> 0.4.0'
117
117
  require 'signet/oauth_1/client'
118
118
  # NOTE: Do not rely on this default value, as it may change
119
119
  new_authorization = Signet::OAuth1::Client.new(
@@ -127,7 +127,7 @@ module Google
127
127
  :client_credential_secret => 'anonymous'
128
128
  )
129
129
  when :two_legged_oauth_1, :two_legged_oauth
130
- gem 'signet', '~> 0.3.0'
130
+ gem 'signet', '~> 0.4.0'
131
131
  require 'signet/oauth_1/client'
132
132
  # NOTE: Do not rely on this default value, as it may change
133
133
  new_authorization = Signet::OAuth1::Client.new(
@@ -136,7 +136,7 @@ module Google
136
136
  :two_legged => true
137
137
  )
138
138
  when :oauth_2
139
- gem 'signet', '~> 0.3.0'
139
+ gem 'signet', '~> 0.4.0'
140
140
  require 'signet/oauth_2/client'
141
141
  # NOTE: Do not rely on this default value, as it may change
142
142
  new_authorization = Signet::OAuth2::Client.new(
@@ -542,7 +542,7 @@ module Google
542
542
  def generate_request(options={})
543
543
  # Note: The merge method on a Hash object will coerce an API Reference
544
544
  # object into a Hash and merge with the default options.
545
-
545
+
546
546
  options={
547
547
  :version => 'v1',
548
548
  :authorization => self.authorization,
@@ -550,7 +550,7 @@ module Google
550
550
  :user_ip => self.user_ip,
551
551
  :connection => Faraday.default_connection
552
552
  }.merge(options)
553
-
553
+
554
554
  # The Reference object is going to need this to do method ID lookups.
555
555
  options[:client] = self
556
556
  # The default value for the :authenticated option depends on whether an
@@ -655,8 +655,10 @@ module Google
655
655
  end
656
656
  end
657
657
 
658
- request = Faraday::Request.create(method.to_s.downcase.to_sym) do |req|
659
- req.url(Addressable::URI.parse(uri))
658
+ request = options[:connection].build_request(
659
+ method.to_s.downcase.to_sym
660
+ ) do |req|
661
+ req.url(Addressable::URI.parse(uri).normalize.to_s)
660
662
  req.headers = Faraday::Utils::Headers.new(headers)
661
663
  req.body = body
662
664
  end
@@ -709,6 +711,7 @@ module Google
709
711
  params.size == 1
710
712
  batch = params.pop
711
713
  options = batch.options
714
+ options[:connection] ||= Faraday.default_connection
712
715
  http_request = batch.to_http_request
713
716
  request = nil
714
717
 
@@ -716,8 +719,10 @@ module Google
716
719
  method, uri, headers, body = http_request
717
720
  method = method.to_s.downcase.to_sym
718
721
 
719
- faraday_request = Faraday::Request.create(method) do |req|
720
- req.url(uri.to_s)
722
+ faraday_request = options[:connection].build_request(
723
+ method.to_s.downcase.to_sym
724
+ ) do |req|
725
+ req.url(Addressable::URI.parse(uri).normalize.to_s)
721
726
  req.headers = Faraday::Utils::Headers.new(headers)
722
727
  req.body = body
723
728
  end
@@ -755,6 +760,7 @@ module Google
755
760
  options[:body] = params.shift if params.size > 0
756
761
  options[:headers] = params.shift if params.size > 0
757
762
  options[:client] = self
763
+ options[:connection] ||= Faraday.default_connection
758
764
  reference = Google::APIClient::Reference.new(options)
759
765
  request = self.generate_request(reference)
760
766
  response = self.transmit(
@@ -772,27 +778,18 @@ module Google
772
778
  # @see Google::APIClient#execute
773
779
  def execute!(*params)
774
780
  result = self.execute(*params)
775
- if result.data?
776
- if result.data.respond_to?(:error) &&
777
- result.data.error.respond_to?(:message)
778
- # You're going to get a terrible error message if the response isn't
779
- # parsed successfully as an error.
780
- error_message = result.data.error.message
781
- elsif result.data['error'] && result.data['error']['message']
782
- error_message = result.data['error']['message']
783
- end
784
- end
785
- if result.response.status >= 400
781
+ if result.error?
782
+ error_message = result.error_message
786
783
  case result.response.status
787
- when 400...500
788
- exception_type = ClientError
789
- error_message ||= "A client error has occurred."
790
- when 500...600
791
- exception_type = ServerError
792
- error_message ||= "A server error has occurred."
793
- else
794
- exception_type = TransmissionError
795
- error_message ||= "A transmission error has occurred."
784
+ when 400...500
785
+ exception_type = ClientError
786
+ error_message ||= "A client error has occurred."
787
+ when 500...600
788
+ exception_type = ServerError
789
+ error_message ||= "A server error has occurred."
790
+ else
791
+ exception_type = TransmissionError
792
+ error_message ||= "A transmission error has occurred."
796
793
  end
797
794
  raise exception_type, error_message
798
795
  end
@@ -24,7 +24,7 @@ module Google
24
24
  ##
25
25
  # Media upload elements for discovered methods
26
26
  class MediaUpload
27
-
27
+
28
28
  ##
29
29
  # Creates a description of a particular method.
30
30
  #
@@ -45,17 +45,17 @@ module Google
45
45
  ##
46
46
  # List of acceptable mime types
47
47
  #
48
- # @return [Array]
48
+ # @return [Array]
49
49
  # List of acceptable mime types for uploaded content
50
50
  def accepted_types
51
51
  @discovery_document['accept']
52
52
  end
53
-
53
+
54
54
  ##
55
55
  # Maximum size of an uplad
56
56
  # TODO: Parse & convert to numeric value
57
57
  #
58
- # @return [String]
58
+ # @return [String]
59
59
  def max_size
60
60
  @discovery_document['maxSize']
61
61
  end
@@ -72,6 +72,6 @@ module Google
72
72
  end
73
73
 
74
74
  end
75
-
75
+
76
76
  end
77
77
  end
@@ -163,7 +163,7 @@ module Google
163
163
  unless k.kind_of?(String)
164
164
  raise TypeError, "Expected String, got #{k.class}."
165
165
  end
166
- accu << [k,v]
166
+ accu << [k, v]
167
167
  accu
168
168
  end
169
169
  else
@@ -204,7 +204,7 @@ module Google
204
204
  # encode all non-template parameters
205
205
  params = ""
206
206
  unless query_parameters.empty?
207
- params = "?" + Addressable::URI.form_encode(query_parameters)
207
+ params = "?" + Addressable::URI.form_encode(query_parameters.sort)
208
208
  end
209
209
  # Normalization is necessary because of undesirable percent-escaping
210
210
  # during URI template expansion
@@ -218,9 +218,12 @@ module Google
218
218
  # The parameters to send.
219
219
  # @param [String, StringIO] body The body for the HTTP request.
220
220
  # @param [Hash, Array] headers The HTTP headers for the request.
221
+ # @option options [Faraday::Connection] :connection
222
+ # The HTTP connection to use.
221
223
  #
222
224
  # @return [Array] The generated HTTP request.
223
- def generate_request(parameters={}, body='', headers=[])
225
+ def generate_request(parameters={}, body='', headers=[], options={})
226
+ options[:connection] ||= Faraday.default_connection
224
227
  if body.respond_to?(:string)
225
228
  body = body.string
226
229
  elsif body.respond_to?(:to_str)
@@ -234,8 +237,10 @@ module Google
234
237
  method = self.http_method
235
238
  uri = self.generate_uri(parameters)
236
239
  headers = headers.to_a if headers.kind_of?(Hash)
237
- return Faraday::Request.create(method.to_s.downcase.to_sym) do |req|
238
- req.url(Addressable::URI.parse(uri))
240
+ return options[:connection].build_request(
241
+ method.to_s.downcase.to_sym
242
+ ) do |req|
243
+ req.url(Addressable::URI.parse(uri).normalize.to_s)
239
244
  req.headers = Faraday::Utils::Headers.new(headers)
240
245
  req.body = body
241
246
  end
@@ -306,7 +311,7 @@ module Google
306
311
  required_variables = ((self.parameter_descriptions.select do |k, v|
307
312
  v['required']
308
313
  end).inject({}) { |h,(k,v)| h[k]=v; h }).keys
309
- missing_variables = required_variables - parameters.map(&:first)
314
+ missing_variables = required_variables - parameters.map { |(k, _)| k }
310
315
  if missing_variables.size > 0
311
316
  raise ArgumentError,
312
317
  "Missing required parameters: #{missing_variables.join(', ')}."
@@ -13,7 +13,7 @@
13
13
  # limitations under the License.
14
14
 
15
15
 
16
- gem 'faraday', '~> 0.7.0'
16
+ gem 'faraday', '~> 0.8.1'
17
17
  require 'faraday'
18
18
  require 'faraday/utils'
19
19
  require 'multi_json'
@@ -26,8 +26,8 @@ require 'google/api_client/discovery'
26
26
  module Google
27
27
  class APIClient
28
28
  class Reference
29
-
30
29
  MULTIPART_BOUNDARY = "-----------RubyApiMultipartPost".freeze
30
+
31
31
  def initialize(options={})
32
32
  # We only need this to do lookups on method ID String values
33
33
  # It's optional, but method ID lookups will fail if the client is
@@ -41,34 +41,57 @@ module Google
41
41
  self.parameters = options[:parameters] || {}
42
42
  # These parameters are handled differently because they're not
43
43
  # parameters to the API method, but rather to the API system.
44
- self.parameters['key'] ||= options[:key] if options[:key]
45
- self.parameters['userIp'] ||= options[:user_ip] if options[:user_ip]
44
+ if self.parameters.kind_of?(Array)
45
+ if options[:key]
46
+ self.parameters.reject! { |k, _| k == 'key' }
47
+ self.parameters << ['key', options[:key]]
48
+ end
49
+ if options[:user_ip]
50
+ self.parameters.reject! { |k, _| k == 'userIp' }
51
+ self.parameters << ['userIp', options[:user_ip]]
52
+ end
53
+ elsif self.parameters.kind_of?(Hash)
54
+ self.parameters['key'] ||= options[:key] if options[:key]
55
+ self.parameters['userIp'] ||= options[:user_ip] if options[:user_ip]
56
+ # Convert to Array, because they're easier to work with when
57
+ # repeated parameters are an issue.
58
+ self.parameters = self.parameters.to_a
59
+ else
60
+ raise TypeError,
61
+ "Expected Array or Hash, got #{self.parameters.class}."
62
+ end
46
63
  self.headers = options[:headers] || {}
47
64
  if options[:media]
48
65
  self.media = options[:media]
49
- upload_type = parameters['uploadType'] || parameters['upload_type']
66
+ upload_type = parameters['uploadType'] || parameters['upload_type']
50
67
  case upload_type
51
68
  when "media"
52
- if options[:body] || options[:body_object]
53
- raise ArgumentError, "Can not specify body & body object for simple uploads"
69
+ if options[:body] || options[:body_object]
70
+ raise ArgumentError,
71
+ "Can not specify body & body object for simple uploads."
54
72
  end
55
73
  self.headers['Content-Type'] ||= self.media.content_type
56
74
  self.body = self.media
57
75
  when "multipart"
58
- unless options[:body_object]
59
- raise ArgumentError, "Multipart requested but no body object"
76
+ unless options[:body_object]
77
+ raise ArgumentError, "Multipart requested but no body object."
60
78
  end
61
- # This is all a bit of a hack due to signet requiring body to be a string
62
- # Ideally, update signet to delay serialization so we can just pass
63
- # streams all the way down through to the HTTP lib
79
+ # This is all a bit of a hack due to Signet requiring body to be a
80
+ # string. Ideally, update Signet to delay serialization so we can
81
+ # just pass streams all the way down through to the HTTP library.
64
82
  metadata = StringIO.new(serialize_body(options[:body_object]))
65
83
  env = {
66
- :request_headers => {'Content-Type' => "multipart/related;boundary=#{MULTIPART_BOUNDARY}"},
67
- :request => { :boundary => MULTIPART_BOUNDARY }
84
+ :request_headers => {
85
+ 'Content-Type' =>
86
+ "multipart/related;boundary=#{MULTIPART_BOUNDARY}"
87
+ },
88
+ :request => {:boundary => MULTIPART_BOUNDARY}
68
89
  }
69
90
  multipart = Faraday::Request::Multipart.new
70
91
  self.body = multipart.create_multipart(env, [
71
- [nil,Faraday::UploadIO.new(metadata, 'application/json', 'file.json')],
92
+ [nil, Faraday::UploadIO.new(
93
+ metadata, 'application/json', 'file.json'
94
+ )],
72
95
  [nil, self.media]])
73
96
  self.headers.update(env[:request_headers])
74
97
  when "resumable"
@@ -77,13 +100,13 @@ module Google
77
100
  self.headers['X-Upload-Content-Length'] = file_length.to_s
78
101
  if options[:body_object]
79
102
  self.headers['Content-Type'] ||= 'application/json'
80
- self.body = serialize_body(options[:body_object])
103
+ self.body = serialize_body(options[:body_object])
81
104
  else
82
105
  self.body = ''
83
106
  end
84
107
  else
85
- raise ArgumentError, "Invalid uploadType for media"
86
- end
108
+ raise ArgumentError, "Invalid uploadType for media."
109
+ end
87
110
  elsif options[:body]
88
111
  self.body = options[:body]
89
112
  elsif options[:body_object]
@@ -96,35 +119,38 @@ module Google
96
119
  self.http_method = options[:http_method] || 'GET'
97
120
  self.uri = options[:uri]
98
121
  unless self.parameters.empty?
99
- self.uri.query_values =
100
- (self.uri.query_values || {}).merge(self.parameters)
122
+ query_values = (self.uri.query_values(Array) || [])
123
+ self.uri.query = Addressable::URI.form_encode(
124
+ (query_values + self.parameters).sort
125
+ )
126
+ self.uri.query = nil if self.uri.query == ""
101
127
  end
102
128
  end
103
129
  end
104
-
130
+
105
131
  def serialize_body(body)
106
132
  return body.to_json if body.respond_to?(:to_json)
107
133
  return MultiJson.dump(options[:body_object].to_hash) if body.respond_to?(:to_hash)
108
134
  raise TypeError, 'Could not convert body object to JSON.' +
109
135
  'Must respond to :to_json or :to_hash.'
110
136
  end
111
-
137
+
112
138
  def media
113
139
  return @media
114
140
  end
115
-
141
+
116
142
  def media=(media)
117
143
  @media = (media)
118
144
  end
119
-
145
+
120
146
  def authorization
121
147
  return @authorization
122
148
  end
123
-
149
+
124
150
  def authorization=(new_authorization)
125
151
  @authorization = new_authorization
126
152
  end
127
-
153
+
128
154
  def connection
129
155
  return @connection
130
156
  end
@@ -199,7 +225,8 @@ module Google
199
225
  accu
200
226
  end).string
201
227
  else
202
- raise TypeError, "Expected body to be String, IO, or Enumerable chunks."
228
+ raise TypeError,
229
+ "Expected body to be String, IO, or Enumerable chunks."
203
230
  end
204
231
  end
205
232
 
@@ -241,13 +268,14 @@ module Google
241
268
  def to_request
242
269
  if self.api_method
243
270
  return self.api_method.generate_request(
244
- self.parameters, self.body, self.headers
271
+ self.parameters, self.body, self.headers,
272
+ :connection => self.connection
245
273
  )
246
274
  else
247
- return Faraday::Request.create(
275
+ return self.connection.build_request(
248
276
  self.http_method.to_s.downcase.to_sym
249
277
  ) do |req|
250
- req.url(Addressable::URI.parse(self.uri))
278
+ req.url(Addressable::URI.parse(self.uri).normalize.to_s)
251
279
  req.headers = Faraday::Utils::Headers.new(self.headers)
252
280
  req.body = self.body
253
281
  end
@@ -266,7 +294,9 @@ module Google
266
294
  options[:headers] = self.headers
267
295
  options[:body] = self.body
268
296
  options[:connection] = self.connection
269
- options[:authorization] = self.authorization unless self.authorization.nil?
297
+ unless self.authorization.nil?
298
+ options[:authorization] = self.authorization
299
+ end
270
300
  return options
271
301
  end
272
302
  end