google-api-ruby-client/generated/google/apis/surveys_v2/service.rb

478 lines
27 KiB
Ruby

# Copyright 2015 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
require 'google/apis/core/base_service'
require 'google/apis/core/json_representation'
require 'google/apis/core/hashable'
require 'google/apis/errors'
module Google
module Apis
module SurveysV2
# Surveys API
#
# Creates and conducts surveys, lists the surveys that an authenticated user
# owns, and retrieves survey results and information about specified surveys.
#
# @example
# require 'google/apis/surveys_v2'
#
# Surveys = Google::Apis::SurveysV2 # Alias the module
# service = Surveys::SurveysService.new
#
class SurveysService < Google::Apis::Core::BaseService
# @return [String]
# API key. Your API key identifies your project and provides you with API access,
# quota, and reports. Required unless you provide an OAuth 2.0 token.
attr_accessor :key
# @return [String]
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# Overrides userIp if both are provided.
attr_accessor :quota_user
# @return [String]
# IP address of the site where the request originates. Use this if you want to
# enforce per-user limits.
attr_accessor :user_ip
def initialize
super('https://www.googleapis.com/', 'surveys/v2/')
end
# Retrieves a MobileAppPanel that is available to the authenticated user.
# @param [String] panel_id
# External URL ID for the panel.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# Overrides userIp if both are provided.
# @param [String] user_ip
# IP address of the site where the request originates. Use this if you want to
# enforce per-user limits.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::SurveysV2::MobileAppPanel] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::SurveysV2::MobileAppPanel]
#
# @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
def get_mobileapppanel(panel_id, fields: nil, quota_user: nil, user_ip: nil, options: nil, &block)
command = make_simple_command(:get, 'mobileAppPanels/{panelId}', options)
command.response_representation = Google::Apis::SurveysV2::MobileAppPanel::Representation
command.response_class = Google::Apis::SurveysV2::MobileAppPanel
command.params['panelId'] = panel_id unless panel_id.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
command.query['userIp'] = user_ip unless user_ip.nil?
execute_or_queue_command(command, &block)
end
# Lists the MobileAppPanels available to the authenticated user.
# @param [Fixnum] max_results
# @param [Fixnum] start_index
# @param [String] token
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# Overrides userIp if both are provided.
# @param [String] user_ip
# IP address of the site where the request originates. Use this if you want to
# enforce per-user limits.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::SurveysV2::MobileAppPanelsListResponse] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::SurveysV2::MobileAppPanelsListResponse]
#
# @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
def list_mobileapppanels(max_results: nil, start_index: nil, token: nil, fields: nil, quota_user: nil, user_ip: nil, options: nil, &block)
command = make_simple_command(:get, 'mobileAppPanels', options)
command.response_representation = Google::Apis::SurveysV2::MobileAppPanelsListResponse::Representation
command.response_class = Google::Apis::SurveysV2::MobileAppPanelsListResponse
command.query['maxResults'] = max_results unless max_results.nil?
command.query['startIndex'] = start_index unless start_index.nil?
command.query['token'] = token unless token.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
command.query['userIp'] = user_ip unless user_ip.nil?
execute_or_queue_command(command, &block)
end
# Updates a MobileAppPanel. Currently the only property that can be updated is
# the owners property.
# @param [String] panel_id
# External URL ID for the panel.
# @param [Google::Apis::SurveysV2::MobileAppPanel] mobile_app_panel_object
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# Overrides userIp if both are provided.
# @param [String] user_ip
# IP address of the site where the request originates. Use this if you want to
# enforce per-user limits.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::SurveysV2::MobileAppPanel] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::SurveysV2::MobileAppPanel]
#
# @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
def update_mobileapppanel(panel_id, mobile_app_panel_object = nil, fields: nil, quota_user: nil, user_ip: nil, options: nil, &block)
command = make_simple_command(:put, 'mobileAppPanels/{panelId}', options)
command.request_representation = Google::Apis::SurveysV2::MobileAppPanel::Representation
command.request_object = mobile_app_panel_object
command.response_representation = Google::Apis::SurveysV2::MobileAppPanel::Representation
command.response_class = Google::Apis::SurveysV2::MobileAppPanel
command.params['panelId'] = panel_id unless panel_id.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
command.query['userIp'] = user_ip unless user_ip.nil?
execute_or_queue_command(command, &block)
end
# Retrieves any survey results that have been produced so far. Results are
# formatted as an Excel file. You must add "?alt=media" to the URL as an
# argument to get results.
# @param [String] survey_url_id
# External URL ID for the survey.
# @param [Google::Apis::SurveysV2::ResultsGetRequest] results_get_request_object
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# Overrides userIp if both are provided.
# @param [String] user_ip
# IP address of the site where the request originates. Use this if you want to
# enforce per-user limits.
# @param [IO, String] download_dest
# IO stream or filename to receive content download
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::SurveysV2::SurveyResults] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::SurveysV2::SurveyResults]
#
# @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
def get_result(survey_url_id, results_get_request_object = nil, fields: nil, quota_user: nil, user_ip: nil, download_dest: nil, options: nil, &block)
if download_dest.nil?
command = make_simple_command(:get, 'surveys/{surveyUrlId}/results', options)
else
command = make_download_command(:get, 'surveys/{surveyUrlId}/results', options)
command.download_dest = download_dest
end
command.request_representation = Google::Apis::SurveysV2::ResultsGetRequest::Representation
command.request_object = results_get_request_object
command.response_representation = Google::Apis::SurveysV2::SurveyResults::Representation
command.response_class = Google::Apis::SurveysV2::SurveyResults
command.params['surveyUrlId'] = survey_url_id unless survey_url_id.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
command.query['userIp'] = user_ip unless user_ip.nil?
execute_or_queue_command(command, &block)
end
# Removes a survey from view in all user GET requests.
# @param [String] survey_url_id
# External URL ID for the survey.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# Overrides userIp if both are provided.
# @param [String] user_ip
# IP address of the site where the request originates. Use this if you want to
# enforce per-user limits.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::SurveysV2::SurveysDeleteResponse] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::SurveysV2::SurveysDeleteResponse]
#
# @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
def delete_survey(survey_url_id, fields: nil, quota_user: nil, user_ip: nil, options: nil, &block)
command = make_simple_command(:delete, 'surveys/{surveyUrlId}', options)
command.response_representation = Google::Apis::SurveysV2::SurveysDeleteResponse::Representation
command.response_class = Google::Apis::SurveysV2::SurveysDeleteResponse
command.params['surveyUrlId'] = survey_url_id unless survey_url_id.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
command.query['userIp'] = user_ip unless user_ip.nil?
execute_or_queue_command(command, &block)
end
# Retrieves information about the specified survey.
# @param [String] survey_url_id
# External URL ID for the survey.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# Overrides userIp if both are provided.
# @param [String] user_ip
# IP address of the site where the request originates. Use this if you want to
# enforce per-user limits.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::SurveysV2::Survey] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::SurveysV2::Survey]
#
# @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
def get_survey(survey_url_id, fields: nil, quota_user: nil, user_ip: nil, options: nil, &block)
command = make_simple_command(:get, 'surveys/{surveyUrlId}', options)
command.response_representation = Google::Apis::SurveysV2::Survey::Representation
command.response_class = Google::Apis::SurveysV2::Survey
command.params['surveyUrlId'] = survey_url_id unless survey_url_id.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
command.query['userIp'] = user_ip unless user_ip.nil?
execute_or_queue_command(command, &block)
end
# Creates a survey.
# @param [Google::Apis::SurveysV2::Survey] survey_object
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# Overrides userIp if both are provided.
# @param [String] user_ip
# IP address of the site where the request originates. Use this if you want to
# enforce per-user limits.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::SurveysV2::Survey] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::SurveysV2::Survey]
#
# @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
def insert_survey(survey_object = nil, fields: nil, quota_user: nil, user_ip: nil, options: nil, &block)
command = make_simple_command(:post, 'surveys', options)
command.request_representation = Google::Apis::SurveysV2::Survey::Representation
command.request_object = survey_object
command.response_representation = Google::Apis::SurveysV2::Survey::Representation
command.response_class = Google::Apis::SurveysV2::Survey
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
command.query['userIp'] = user_ip unless user_ip.nil?
execute_or_queue_command(command, &block)
end
# Lists the surveys owned by the authenticated user.
# @param [Fixnum] max_results
# @param [Fixnum] start_index
# @param [String] token
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# Overrides userIp if both are provided.
# @param [String] user_ip
# IP address of the site where the request originates. Use this if you want to
# enforce per-user limits.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::SurveysV2::SurveysListResponse] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::SurveysV2::SurveysListResponse]
#
# @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
def list_surveys(max_results: nil, start_index: nil, token: nil, fields: nil, quota_user: nil, user_ip: nil, options: nil, &block)
command = make_simple_command(:get, 'surveys', options)
command.response_representation = Google::Apis::SurveysV2::SurveysListResponse::Representation
command.response_class = Google::Apis::SurveysV2::SurveysListResponse
command.query['maxResults'] = max_results unless max_results.nil?
command.query['startIndex'] = start_index unless start_index.nil?
command.query['token'] = token unless token.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
command.query['userIp'] = user_ip unless user_ip.nil?
execute_or_queue_command(command, &block)
end
# Begins running a survey.
# @param [String] resource_id
# @param [Google::Apis::SurveysV2::SurveysStartRequest] surveys_start_request_object
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# Overrides userIp if both are provided.
# @param [String] user_ip
# IP address of the site where the request originates. Use this if you want to
# enforce per-user limits.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::SurveysV2::SurveysStartResponse] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::SurveysV2::SurveysStartResponse]
#
# @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
def start_survey(resource_id, surveys_start_request_object = nil, fields: nil, quota_user: nil, user_ip: nil, options: nil, &block)
command = make_simple_command(:post, 'surveys/{resourceId}/start', options)
command.request_representation = Google::Apis::SurveysV2::SurveysStartRequest::Representation
command.request_object = surveys_start_request_object
command.response_representation = Google::Apis::SurveysV2::SurveysStartResponse::Representation
command.response_class = Google::Apis::SurveysV2::SurveysStartResponse
command.params['resourceId'] = resource_id unless resource_id.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
command.query['userIp'] = user_ip unless user_ip.nil?
execute_or_queue_command(command, &block)
end
# Stops a running survey.
# @param [String] resource_id
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# Overrides userIp if both are provided.
# @param [String] user_ip
# IP address of the site where the request originates. Use this if you want to
# enforce per-user limits.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::SurveysV2::SurveysStopResponse] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::SurveysV2::SurveysStopResponse]
#
# @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
def stop_survey(resource_id, fields: nil, quota_user: nil, user_ip: nil, options: nil, &block)
command = make_simple_command(:post, 'surveys/{resourceId}/stop', options)
command.response_representation = Google::Apis::SurveysV2::SurveysStopResponse::Representation
command.response_class = Google::Apis::SurveysV2::SurveysStopResponse
command.params['resourceId'] = resource_id unless resource_id.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
command.query['userIp'] = user_ip unless user_ip.nil?
execute_or_queue_command(command, &block)
end
# Updates a survey. Currently the only property that can be updated is the
# owners property.
# @param [String] survey_url_id
# External URL ID for the survey.
# @param [Google::Apis::SurveysV2::Survey] survey_object
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# Overrides userIp if both are provided.
# @param [String] user_ip
# IP address of the site where the request originates. Use this if you want to
# enforce per-user limits.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::SurveysV2::Survey] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::SurveysV2::Survey]
#
# @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
def update_survey(survey_url_id, survey_object = nil, fields: nil, quota_user: nil, user_ip: nil, options: nil, &block)
command = make_simple_command(:put, 'surveys/{surveyUrlId}', options)
command.request_representation = Google::Apis::SurveysV2::Survey::Representation
command.request_object = survey_object
command.response_representation = Google::Apis::SurveysV2::Survey::Representation
command.response_class = Google::Apis::SurveysV2::Survey
command.params['surveyUrlId'] = survey_url_id unless survey_url_id.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
command.query['userIp'] = user_ip unless user_ip.nil?
execute_or_queue_command(command, &block)
end
protected
def apply_command_defaults(command)
command.query['key'] = key unless key.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
command.query['userIp'] = user_ip unless user_ip.nil?
end
end
end
end
end