createDocument method
Creates a new document.
Throws a http.ClientException if there were problems communicating with
the API service. Throws a ServiceException if the API method failed for
any reason.
Implementation
Future<Document> createDocument(CreateDocumentRequest request) async {
final url = _endPoint.replace(
path: '/v1/${request.parent}/${request.collectionId}',
queryParameters: {
if (request.documentId case final $1 when $1.isNotDefault)
'documentId': $1,
if (request.mask?.fieldPaths case final $1? when $1.isNotDefault)
'mask.fieldPaths': $1,
},
);
final response = await _client.post(url, body: request.document);
return Document.fromJson(response);
}