Added code to determine the location of the discovery document.

git-svn-id: https://google-api-ruby-client.googlecode.com/svn/trunk@11 c1d61fac-ed7f-fcc1-18f7-ff78120a04ef
This commit is contained in:
bobaman@google.com 2010-08-14 01:26:01 +00:00
parent a6d7aa570e
commit 25786356d3
2 changed files with 19 additions and 0 deletions

View File

@ -52,6 +52,8 @@ module Google #:nodoc:
#
# @param [Hash] options
# The configuration options.
# <code>:service</code>::
# The name of the service.
# <code>:request_token_uri</code>::
# The OAuth endpoint for obtaining a request token.
# <code>:authorization_uri</code>::

View File

@ -34,6 +34,12 @@ module Google #:nodoc:
# Creates a new API discovery handler.
#
# @param [Hash] options
# <code>:service</code>::
# The name of the service.
# <code>:service_version</code>::
# The version of the service.
# <code>:discovery_uri</code>::
# The URI of the discovery document.
#
# @return [Google::APIClient::Discovery] The API discovery handler.
def initialize(options={})
@ -43,6 +49,17 @@ module Google #:nodoc:
@options = DEFAULTS.clone
end
@options.merge!(options)
if @options[:service] && !@options[:discovery_uri]
service_id = @options[:service]
service_version = @options[:service_version] || "1.0"
@options[:discovery_uri] =
"http://www.googleapis.com/discovery/0.1/describe" +
"?api=#{service_id}&apiVersion=#{service_version}"
end
unless @options[:discovery_uri]
raise ArgumentError,
"Missing required configuration value, :discovery_uri."
end
# Handle any remaining configuration here
end