getMedia method

Future<GoogleMapsPlacesV1PhotoMedia> getMedia(
  1. String name, {
  2. int? maxHeightPx,
  3. int? maxWidthPx,
  4. bool? skipHttpRedirect,
  5. String? $fields,
})

Get a photo media with a photo reference string.

Request parameters:

name - Required. The resource name of a photo media in the format: places/{place_id}/photos/{photo_reference}/media. The resource name of a photo as returned in a Place object's photos.name field comes with the format places/{place_id}/photos/{photo_reference}. You need to append /media at the end of the photo resource to get the photo media resource name. Value must have pattern ^places/\[^/\]+/photos/\[^/\]+/media$.

maxHeightPx - Optional. Specifies the maximum desired height, in pixels, of the image. If the image is smaller than the values specified, the original image will be returned. If the image is larger in either dimension, it will be scaled to match the smaller of the two dimensions, restricted to its original aspect ratio. Both the max_height_px and max_width_px properties accept an integer between 1 and 4800, inclusively. If the value is not within the allowed range, an INVALID_ARGUMENT error will be returned. At least one of max_height_px or max_width_px needs to be specified. If neither max_height_px nor max_width_px is specified, an INVALID_ARGUMENT error will be returned.

maxWidthPx - Optional. Specifies the maximum desired width, in pixels, of the image. If the image is smaller than the values specified, the original image will be returned. If the image is larger in either dimension, it will be scaled to match the smaller of the two dimensions, restricted to its original aspect ratio. Both the max_height_px and max_width_px properties accept an integer between 1 and 4800, inclusively. If the value is not within the allowed range, an INVALID_ARGUMENT error will be returned. At least one of max_height_px or max_width_px needs to be specified. If neither max_height_px nor max_width_px is specified, an INVALID_ARGUMENT error will be returned.

skipHttpRedirect - Optional. If set, skip the default HTTP redirect behavior and render a text format (for example, in JSON format for HTTP use case) response. If not set, an HTTP redirect will be issued to redirect the call to the image media. This option is ignored for non-HTTP requests.

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

Completes with a GoogleMapsPlacesV1PhotoMedia.

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<GoogleMapsPlacesV1PhotoMedia> getMedia(
  core.String name, {
  core.int? maxHeightPx,
  core.int? maxWidthPx,
  core.bool? skipHttpRedirect,
  core.String? $fields,
}) async {
  final queryParams_ = <core.String, core.List<core.String>>{
    if (maxHeightPx != null) 'maxHeightPx': ['${maxHeightPx}'],
    if (maxWidthPx != null) 'maxWidthPx': ['${maxWidthPx}'],
    if (skipHttpRedirect != null) 'skipHttpRedirect': ['${skipHttpRedirect}'],
    if ($fields != null) 'fields': [$fields],
  };

  final url_ = 'v1/' + core.Uri.encodeFull('$name');

  final response_ = await _requester.request(
    url_,
    'GET',
    queryParams: queryParams_,
  );
  return GoogleMapsPlacesV1PhotoMedia.fromJson(
      response_ as core.Map<core.String, core.dynamic>);
}