# The writer method understands a few Symbols and will generate useful
# default authentication mechanisms.
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.
# By default, Net::HTTP is used, but adding support for other clients
# is trivial.
return @authorization
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.
#
# object into a Hash and merge with the default options.
options={
:version => 'v1',
- :authorization => self.authorization
+ :authorization => self.authorization,
+ :key => self.key,
+ :user_ip => self.user_ip
}.merge(options)
# The Reference object is going to need this to do method ID lookups.
options[:client] = self
self.api_method = options[:api_method]
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] || []
if options[:body]
self.body = options[:body]