Added better support for user IP and developer key across all APIs.
This commit is contained in:
parent
5c4323b11c
commit
d2907c9d79
|
@ -70,6 +70,8 @@ module Google
|
||||||
# The writer method understands a few Symbols and will generate useful
|
# The writer method understands a few Symbols and will generate useful
|
||||||
# default authentication mechanisms.
|
# default authentication mechanisms.
|
||||||
self.authorization = options["authorization"] || :oauth_2
|
self.authorization = options["authorization"] || :oauth_2
|
||||||
|
self.key = options["key"]
|
||||||
|
self.user_ip = options["user_ip"]
|
||||||
# The HTTP adapter controls all of the HTTP traffic the client generates.
|
# The HTTP adapter controls all of the HTTP traffic the client generates.
|
||||||
# By default, Net::HTTP is used, but adding support for other clients
|
# By default, Net::HTTP is used, but adding support for other clients
|
||||||
# is trivial.
|
# is trivial.
|
||||||
|
@ -142,6 +144,18 @@ module Google
|
||||||
return @authorization
|
return @authorization
|
||||||
end
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
# The application's API key issued by the API console.
|
||||||
|
#
|
||||||
|
# @return [String] The API key..
|
||||||
|
attr_accessor :key
|
||||||
|
|
||||||
|
##
|
||||||
|
# The IP address of the user this request is being performed on behalf of.
|
||||||
|
#
|
||||||
|
# @return [String] The user's IP address.
|
||||||
|
attr_accessor :user_ip
|
||||||
|
|
||||||
##
|
##
|
||||||
# Returns the HTTP adapter used by the client.
|
# Returns the HTTP adapter used by the client.
|
||||||
#
|
#
|
||||||
|
@ -440,7 +454,9 @@ module Google
|
||||||
# object into a Hash and merge with the default options.
|
# object into a Hash and merge with the default options.
|
||||||
options={
|
options={
|
||||||
:version => 'v1',
|
:version => 'v1',
|
||||||
:authorization => self.authorization
|
:authorization => self.authorization,
|
||||||
|
:key => self.key,
|
||||||
|
:user_ip => self.user_ip
|
||||||
}.merge(options)
|
}.merge(options)
|
||||||
# The Reference object is going to need this to do method ID lookups.
|
# The Reference object is going to need this to do method ID lookups.
|
||||||
options[:client] = self
|
options[:client] = self
|
||||||
|
|
|
@ -29,6 +29,10 @@ module Google
|
||||||
|
|
||||||
self.api_method = options[:api_method]
|
self.api_method = options[:api_method]
|
||||||
self.parameters = options[:parameters] || {}
|
self.parameters = options[:parameters] || {}
|
||||||
|
# These parameters are handled differently because they're not
|
||||||
|
# parameters to the API method, but rather to the API system.
|
||||||
|
self.parameters['key'] ||= options[:key] if options[:key]
|
||||||
|
self.parameters['user_ip'] ||= options[:user_ip] if options[:user_ip]
|
||||||
self.headers = options[:headers] || []
|
self.headers = options[:headers] || []
|
||||||
if options[:body]
|
if options[:body]
|
||||||
self.body = options[:body]
|
self.body = options[:body]
|
||||||
|
|
Loading…
Reference in New Issue