get method
Gets the latest version of the specified document.
Request parameters:
documentId - The ID of the document to retrieve.
commentsViewMode - The comments view mode to apply to the document. This
allows viewing the document with comments omitted or included. If one is
not specified, COMMENTS_VIEW_MODE_OMITTED is used. If you set
comments_view_mode to any value, you must also set include_tabs_content to
true or use a field mask that references the Document.tabs field (or any
subfield). If you set comments_view_mode to COMMENTS_VIEW_MODE_INCLUDED,
you must also explicitly set suggestions_view_mode to SUGGESTIONS_INLINE.
If you set comments_view_mode to COMMENTS_VIEW_MODE_INCLUDED or
COMMENTS_VIEW_MODE_DEFAULT_FOR_CURRENT_ACCESS, you may not set
suggestions_view_mode to PREVIEW_WITHOUT_SUGGESTIONS or
PREVIEW_SUGGESTIONS_ACCEPTED.
Possible string values are:
- "COMMENTS_VIEW_MODE_UNSPECIFIED" : The CommentsViewMode is unspecified. COMMENTS_VIEW_MODE_OMITTED is applied.
- "COMMENTS_VIEW_MODE_DEFAULT_FOR_CURRENT_ACCESS" : The CommentsViewMode applied to the returned document depends on the user's current access level. If the user only has view access, COMMENTS_VIEW_MODE_OMITTED is applied. Otherwise, COMMENTS_VIEW_MODE_INCLUDED is applied.
- "COMMENTS_VIEW_MODE_OMITTED" : The returned document has comments omitted.
- "COMMENTS_VIEW_MODE_INCLUDED" : The returned document has comments included. Requests to retrieve a document using this mode will return a 403 error if the user does not have permission to view comments. When set, suggestions_view_mode must also be set to SUGGESTIONS_INLINE. Returns a 400 bad request error otherwise.
includeTabsContent - 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. If you use a field mask that references the
Document.tabs field (or any subfield), the API implicitly treats the
request as if you set include_tabs_content to true.
suggestionsViewMode - 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.
Possible string values are:
- "DEFAULT_FOR_CURRENT_ACCESS" : The SuggestionsViewMode applied to the returned document depends on the user's current access level. If the user only has view access, PREVIEW_WITHOUT_SUGGESTIONS is applied. Otherwise, SUGGESTIONS_INLINE is applied. This is the default suggestions view mode.
- "SUGGESTIONS_INLINE" : The returned document has suggestions inline. Suggested changes will be differentiated from base content within the document. Requests to retrieve a document using this mode will return a 403 error if the user does not have permission to view suggested changes.
- "PREVIEW_SUGGESTIONS_ACCEPTED" : The returned document is a preview with all suggested changes accepted. Requests to retrieve a document using this mode will return a 403 error if the user does not have permission to view suggested changes.
- "PREVIEW_WITHOUT_SUGGESTIONS" : The returned document is a preview with all suggested changes rejected if there are any suggestions in the document.
$fields - Selector specifying which fields to include in a partial
response.
Completes with a Document.
Completes with a commons.ApiRequestError if the API endpoint returned an error.
If the used http.Client completes with an error when making a REST call,
this method will complete with the same error.
Implementation
async.Future<Document> get(
core.String documentId, {
core.String? commentsViewMode,
core.bool? includeTabsContent,
core.String? suggestionsViewMode,
core.String? $fields,
}) async {
final queryParams_ = <core.String, core.List<core.String>>{
'commentsViewMode': ?commentsViewMode == null ? null : [commentsViewMode],
'includeTabsContent': ?includeTabsContent == null
? null
: ['${includeTabsContent}'],
'suggestionsViewMode': ?suggestionsViewMode == null
? null
: [suggestionsViewMode],
'fields': ?$fields == null ? null : [$fields],
};
final url_ = 'v1/documents/' + commons.escapeVariable('$documentId');
final response_ = await _requester.request(
url_,
'GET',
queryParams: queryParams_,
);
return Document.fromJson(response_ as core.Map<core.String, core.dynamic>);
}