Class: Google::Apis::DocsV1::DocsService

Inherits:
Core::BaseService
  • Object
show all
Defined in:
lib/google/apis/docs_v1/service.rb

Overview

Google Docs API

Reads and writes Google Docs documents.

Examples:

require 'google/apis/docs_v1'

Docs = Google::Apis::DocsV1 # Alias the module
service = Docs::DocsService.new

See Also:

Constant Summary collapse

DEFAULT_ENDPOINT_TEMPLATE =
"https://docs.$UNIVERSE_DOMAIN$/"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDocsService

Returns a new instance of DocsService.



47
48
49
50
51
52
# File 'lib/google/apis/docs_v1/service.rb', line 47

def initialize
  super(DEFAULT_ENDPOINT_TEMPLATE, '',
        client_name: 'google-apis-docs_v1',
        client_version: Google::Apis::DocsV1::GEM_VERSION)
  @batch_path = 'batch'
end

Instance Attribute Details

#keyString

Returns 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.

Returns:

  • (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.



40
41
42
# File 'lib/google/apis/docs_v1/service.rb', line 40

def key
  @key
end

#quota_userString

Returns 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.

Returns:

  • (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.



45
46
47
# File 'lib/google/apis/docs_v1/service.rb', line 45

def quota_user
  @quota_user
end

Instance Method Details

#batch_update_document(document_id, batch_update_document_request_object = nil, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::DocsV1::BatchUpdateDocumentResponse

Applies one or more updates to the document. Each request is validated before being applied. If any request is not valid, then the entire request will fail and nothing will be applied. Some requests have replies to give you some information about how they are applied. Other requests do not need to return information; these each return an empty reply. The order of replies matches that of the requests. For example, suppose you call batchUpdate with four updates, and only the third one returns information. The response would have two empty replies, the reply to the third request, and another empty reply, in that order. Because other users may be editing the document, the document might not exactly reflect your changes: your changes may be altered with respect to collaborator changes. If there are no collaborators, the document should reflect your changes. In any case, the updates in your request are guaranteed to be applied together atomically.

Parameters:

  • document_id (String)

    The ID of the document to update.

  • batch_update_document_request_object (Google::Apis::DocsV1::BatchUpdateDocumentRequest) (defaults to: nil)
  • fields (String) (defaults to: nil)

    Selector specifying which fields to include in a partial response.

  • quota_user (String) (defaults to: nil)

    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.

  • options (Google::Apis::RequestOptions) (defaults to: nil)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Returns:

Raises:

  • (Google::Apis::ServerError)

    An error occurred on the server and the request can be retried

  • (Google::Apis::ClientError)

    The request is invalid and should not be retried without modification

  • (Google::Apis::AuthorizationError)

    Authorization is required



87
88
89
90
91
92
93
94
95
96
97
# File 'lib/google/apis/docs_v1/service.rb', line 87

def batch_update_document(document_id, batch_update_document_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
  command = make_simple_command(:post, 'v1/documents/{documentId}:batchUpdate', options)
  command.request_representation = Google::Apis::DocsV1::BatchUpdateDocumentRequest::Representation
  command.request_object = batch_update_document_request_object
  command.response_representation = Google::Apis::DocsV1::BatchUpdateDocumentResponse::Representation
  command.response_class = Google::Apis::DocsV1::BatchUpdateDocumentResponse
  command.params['documentId'] = document_id unless document_id.nil?
  command.query['fields'] = fields unless fields.nil?
  command.query['quotaUser'] = quota_user unless quota_user.nil?
  execute_or_queue_command(command, &block)
end

#create_document(document_object = nil, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::DocsV1::Document

Creates a blank document using the title given in the request. Other fields in the request, including any provided content, are ignored. Returns the created document.

Parameters:

  • document_object (Google::Apis::DocsV1::Document) (defaults to: nil)
  • fields (String) (defaults to: nil)

    Selector specifying which fields to include in a partial response.

  • quota_user (String) (defaults to: nil)

    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.

  • options (Google::Apis::RequestOptions) (defaults to: nil)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Returns:

Raises:

  • (Google::Apis::ServerError)

    An error occurred on the server and the request can be retried

  • (Google::Apis::ClientError)

    The request is invalid and should not be retried without modification

  • (Google::Apis::AuthorizationError)

    Authorization is required



120
121
122
123
124
125
126
127
128
129
# File 'lib/google/apis/docs_v1/service.rb', line 120

def create_document(document_object = nil, fields: nil, quota_user: nil, options: nil, &block)
  command = make_simple_command(:post, 'v1/documents', options)
  command.request_representation = Google::Apis::DocsV1::Document::Representation
  command.request_object = document_object
  command.response_representation = Google::Apis::DocsV1::Document::Representation
  command.response_class = Google::Apis::DocsV1::Document
  command.query['fields'] = fields unless fields.nil?
  command.query['quotaUser'] = quota_user unless quota_user.nil?
  execute_or_queue_command(command, &block)
end

#get_document(document_id, include_tabs_content: nil, suggestions_view_mode: nil, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::DocsV1::Document

Gets the latest version of the specified document.

Parameters:

  • document_id (String)

    The ID of the document to retrieve.

  • include_tabs_content (Boolean) (defaults to: nil)

    Whether to populate the Document.tabs field instead of the text content fields like body and documentStyle on Document. - When True: Document content populates in the Document.tabs field instead of the text content fields in Document. - When False: The content of the document's first tab populates the content fields in Document excluding Document.tabs. If a document has only one tab, then that tab is used to populate the document content. Document.tabs will be empty.

  • suggestions_view_mode (String) (defaults to: nil)

    The suggestions view mode to apply to the document. This allows viewing the document with all suggestions inline, accepted or rejected. If one is not specified, DEFAULT_FOR_CURRENT_ACCESS is used.

  • fields (String) (defaults to: nil)

    Selector specifying which fields to include in a partial response.

  • quota_user (String) (defaults to: nil)

    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.

  • options (Google::Apis::RequestOptions) (defaults to: nil)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Returns:

Raises:

  • (Google::Apis::ServerError)

    An error occurred on the server and the request can be retried

  • (Google::Apis::ClientError)

    The request is invalid and should not be retried without modification

  • (Google::Apis::AuthorizationError)

    Authorization is required



163
164
165
166
167
168
169
170
171
172
173
# File 'lib/google/apis/docs_v1/service.rb', line 163

def get_document(document_id, include_tabs_content: nil, suggestions_view_mode: nil, fields: nil, quota_user: nil, options: nil, &block)
  command = make_simple_command(:get, 'v1/documents/{documentId}', options)
  command.response_representation = Google::Apis::DocsV1::Document::Representation
  command.response_class = Google::Apis::DocsV1::Document
  command.params['documentId'] = document_id unless document_id.nil?
  command.query['includeTabsContent'] = include_tabs_content unless include_tabs_content.nil?
  command.query['suggestionsViewMode'] = suggestions_view_mode unless suggestions_view_mode.nil?
  command.query['fields'] = fields unless fields.nil?
  command.query['quotaUser'] = quota_user unless quota_user.nil?
  execute_or_queue_command(command, &block)
end