download method

Future<Object> download(
  1. String name, {
  2. String? $fields,
  3. DownloadOptions downloadOptions = commons.DownloadOptions.metadata,
})

Download a file attachment on a case.

Note: HTTP requests must append "?alt=media" to the URL.

Request parameters:

name - The resource name of the attachment to be downloaded. Value must have pattern ^\[^/\]+/\[^/\]+/cases/\[^/\]+/attachments/\[^/\]+$.

$fields - Selector specifying which fields to include in a partial response.

downloadOptions - Options for downloading. A download can be either a Metadata (default) or Media download. Partial Media downloads are possible as well.

Completes with a

  • Media for Metadata downloads (see downloadOptions).

  • commons.Media for Media downloads (see downloadOptions).

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<core.Object> download(
  core.String name, {
  core.String? $fields,
  commons.DownloadOptions downloadOptions = commons.DownloadOptions.metadata,
}) async {
  final _queryParams = <core.String, core.List<core.String>>{
    if ($fields != null) 'fields': [$fields],
  };

  final _url = 'v2beta/' + core.Uri.encodeFull('$name') + ':download';

  final _response = await _requester.request(
    _url,
    'GET',
    queryParams: _queryParams,
    downloadOptions: downloadOptions,
  );
  if (downloadOptions.isMetadataDownload) {
    return Media.fromJson(_response as core.Map<core.String, core.dynamic>);
  } else {
    return _response as commons.Media;
  }
}