2015-04-17 00:28:38 +00:00
|
|
|
|
|
|
|
# <%= block_comment(api_method.description, 0, 1) %>
|
2015-07-31 00:05:05 +00:00
|
|
|
<% for param in api_method.required_parameters -%>
|
2015-04-17 00:28:38 +00:00
|
|
|
# @param [<% if param.repeated? %>Array<<%= param.generated_type %>>, <% end %><%= param.generated_type %>] <%= param.generated_name %>
|
|
|
|
<% if param.description -%>
|
|
|
|
# <%= block_comment(param.description, 0, 3) %>
|
|
|
|
<% end -%>
|
|
|
|
<% end -%>
|
|
|
|
<% if api_method.request -%>
|
|
|
|
# @param [<%= api.schemas[api_method.request._ref].generated_type %>] <%= api.schemas[api_method.request._ref].generated_name %>_object
|
|
|
|
<% end -%>
|
2015-07-31 00:05:05 +00:00
|
|
|
<% for param in api_method.optional_query_parameters -%>
|
2015-04-17 00:28:38 +00:00
|
|
|
# @param [<% if param.repeated? %>Array<<%= param.generated_type %>>, <% end %><%= param.generated_type %>] <%= param.generated_name %>
|
|
|
|
<% if param.description -%>
|
|
|
|
# <%= block_comment(param.description, 0, 3) %>
|
|
|
|
<% end -%>
|
|
|
|
<% end -%>
|
|
|
|
<% for param in api.parameters.values.reject {|p| p.name == 'key'} -%>
|
|
|
|
# @param [<% if param.repeated? %>Array<<%= param.generated_type %>>, <% end %><%= param.generated_type %>] <%= param.generated_name %>
|
|
|
|
<% if param.description -%>
|
|
|
|
# <%= block_comment(param.description, 0, 3) %>
|
|
|
|
<% end -%>
|
|
|
|
<% end -%>
|
|
|
|
<% if api_method.supports_media_upload? -%>
|
|
|
|
# @param [IO, String] upload_source
|
|
|
|
# IO stream or filename containing content to upload
|
|
|
|
# @param [String] content_type
|
|
|
|
# Content type of the uploaded content.
|
|
|
|
<% elsif api_method.supports_media_download? -%>
|
|
|
|
# @param [IO, String] download_dest
|
|
|
|
# IO stream or filename to receive content download
|
|
|
|
<% end -%>
|
|
|
|
# @param [Google::Apis::RequestOptions] options
|
|
|
|
# Request-specific options
|
|
|
|
#
|
|
|
|
# @yield [result, err] Result & error if block supplied
|
|
|
|
<% if api_method.response -%>
|
|
|
|
# @yieldparam result [<%= api.schemas[api_method.response._ref].generated_type %>] parsed result object
|
|
|
|
# @yieldparam err [StandardError] error object if request failed
|
|
|
|
#
|
|
|
|
# @return [<%= api.schemas[api_method.response._ref].generated_type %>]
|
|
|
|
<% else -%>
|
|
|
|
# @yieldparam result [NilClass] No result returned for this method
|
|
|
|
# @yieldparam err [StandardError] error object if request failed
|
|
|
|
#
|
|
|
|
# @return [void]
|
|
|
|
<% end -%>
|
|
|
|
#
|
|
|
|
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
|
|
|
|
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
|
|
|
|
# @raise [Google::Apis::AuthorizationError] Authorization is required
|
2015-07-31 00:05:05 +00:00
|
|
|
def <%= api_method.generated_name %>(<% for param in api_method.required_parameters %><%= param.generated_name %>, <% end %><% if api_method.request %><%= api.schemas[api_method.request._ref].generated_name %>_object = nil, <% end %><% for param in api_method.optional_query_parameters %><%= param.generated_name %>: nil, <% end %><% for param in api.parameters.values.reject {|p| p.name == 'key'} %><%= param.generated_name %>: nil, <% end %><% if api_method.supports_media_upload? %>upload_source: nil, content_type: nil, <% elsif api_method.supports_media_download? %>download_dest: nil, <% end %>options: nil, &block)
|
2015-04-17 00:28:38 +00:00
|
|
|
<% if api_method.supports_media_upload? -%>
|
|
|
|
if upload_source.nil?
|
2015-08-13 19:08:28 +00:00
|
|
|
command = make_simple_command(:<%= api_method.http_method.downcase %>, '<%= api_method.path %>', options)
|
2015-04-17 00:28:38 +00:00
|
|
|
else
|
2015-08-13 19:08:28 +00:00
|
|
|
command = make_upload_command(:<%= api_method.http_method.downcase %>, '<%= api_method.path %>', options)
|
2015-04-17 00:28:38 +00:00
|
|
|
command.upload_source = upload_source
|
|
|
|
command.upload_content_type = content_type
|
|
|
|
end
|
|
|
|
<% elsif api_method.supports_media_download? -%>
|
|
|
|
if download_dest.nil?
|
2015-08-13 19:08:28 +00:00
|
|
|
command = make_simple_command(:<%= api_method.http_method.downcase %>, '<%= api_method.path %>', options)
|
2015-04-17 00:28:38 +00:00
|
|
|
else
|
2015-08-13 19:08:28 +00:00
|
|
|
command = make_download_command(:<%= api_method.http_method.downcase %>, '<%= api_method.path %>', options)
|
2015-04-17 00:28:38 +00:00
|
|
|
command.download_dest = download_dest
|
|
|
|
end
|
|
|
|
<% else -%>
|
2015-08-13 19:08:28 +00:00
|
|
|
command = make_simple_command(:<%= api_method.http_method.downcase %>, '<%= api_method.path %>', options)
|
2015-04-17 00:28:38 +00:00
|
|
|
<% end -%>
|
|
|
|
<% if api_method.request -%>
|
|
|
|
command.request_representation = <%= api.schemas[api_method.request._ref].generated_type %>::Representation
|
|
|
|
command.request_object = <%= api.schemas[api_method.request._ref].generated_name %>_object
|
|
|
|
<% end -%>
|
|
|
|
<% if api_method.response -%>
|
2016-01-14 18:48:40 +00:00
|
|
|
<% if api.force_alt_json? -%>
|
|
|
|
command.query['alt'] = 'json'
|
|
|
|
<% end -%>
|
2015-04-17 00:28:38 +00:00
|
|
|
command.response_representation = <%= api.schemas[api_method.response._ref].generated_type %>::Representation
|
|
|
|
command.response_class = <%= api.schemas[api_method.response._ref].generated_type %>
|
|
|
|
<% end -%>
|
|
|
|
<% for param in api_method.path_parameters -%>
|
|
|
|
command.params['<%= param.name %>'] = <%= param.generated_name %> unless <%= param.generated_name %>.nil?
|
|
|
|
<% end -%>
|
|
|
|
<% for param in api_method.query_parameters -%>
|
|
|
|
command.query['<%= param.name %>'] = <%= param.generated_name %> unless <%= param.generated_name %>.nil?
|
|
|
|
<% end -%>
|
|
|
|
<% for param in api.parameters.values.reject {|p| p.name == 'key'} -%>
|
|
|
|
command.query['<%= param.name %>'] = <%= param.generated_name %> unless <%= param.generated_name %>.nil?
|
|
|
|
<% end -%>
|
|
|
|
execute_or_queue_command(command, &block)
|
|
|
|
end
|