getPlace method

Future<GetPlaceResponse> getPlace({
  1. required String placeId,
  2. List<GetPlaceAdditionalFeature>? additionalFeatures,
  3. GetPlaceIntendedUse? intendedUse,
  4. String? key,
  5. String? language,
  6. String? politicalView,
})

GetPlace finds a place by its unique ID. A PlaceId is returned by other place operations.

For more information, see GetPlace in the Amazon Location Service Developer Guide.

May throw AccessDeniedException. May throw InternalServerException. May throw ThrottlingException. May throw ValidationException.

Parameter placeId : The PlaceId of the place you wish to receive the information for.

Parameter additionalFeatures : A list of optional additional parameters such as time zone that can be requested for each result. For GrabMaps customers, ap-southeast-1 and ap-southeast-5 regions support only the TimeZone value.

Parameter intendedUse : Indicates if the query results will be persisted in customer infrastructure. Defaults to SingleUse (not stored). Not supported in ap-southeast-1 and ap-southeast-5 regions for GrabMaps customers.

Parameter key : Optional: The API key to be used for authorization. Either an API key or valid SigV4 signature must be provided when making a request.

Parameter language : A list of BCP 47 compliant language codes for the results to be rendered in. If there is no data for the result in the requested language, data will be returned in the default language for the entry. For GrabMaps customers, ap-southeast-1 and ap-southeast-5 regions support only the following codes: en, id, km, lo, ms, my, pt, th, tl, vi, zh

Parameter politicalView : The alpha-2 or alpha-3 character code for the political view of a country. The political view applies to the results of the request to represent unresolved territorial claims through the point of view of the specified country. Not supported in ap-southeast-1 and ap-southeast-5 regions for GrabMaps customers.

Implementation

Future<GetPlaceResponse> getPlace({
  required String placeId,
  List<GetPlaceAdditionalFeature>? additionalFeatures,
  GetPlaceIntendedUse? intendedUse,
  String? key,
  String? language,
  String? politicalView,
}) async {
  final $query = <String, List<String>>{
    if (additionalFeatures != null)
      'additional-features': additionalFeatures.map((e) => e.value).toList(),
    if (intendedUse != null) 'intended-use': [intendedUse.value],
    if (key != null) 'key': [key],
    if (language != null) 'language': [language],
    if (politicalView != null) 'political-view': [politicalView],
  };
  final response = await _protocol.sendRaw(
    payload: null,
    method: 'GET',
    requestUri: '/v2/place/${Uri.encodeComponent(placeId)}',
    queryParams: $query,
    exceptionFnMap: _exceptionFns,
  );
  final $json = await _s.jsonFromResponse(response);
  return GetPlaceResponse(
    placeId: ($json['PlaceId'] as String?) ?? '',
    placeType: PlaceType.fromString(($json['PlaceType'] as String?) ?? ''),
    title: ($json['Title'] as String?) ?? '',
    accessPoints: ($json['AccessPoints'] as List?)
        ?.nonNulls
        .map((e) => AccessPoint.fromJson(e as Map<String, dynamic>))
        .toList(),
    accessRestrictions: ($json['AccessRestrictions'] as List?)
        ?.nonNulls
        .map((e) => AccessRestriction.fromJson(e as Map<String, dynamic>))
        .toList(),
    address: $json['Address'] != null
        ? Address.fromJson($json['Address'] as Map<String, dynamic>)
        : null,
    addressNumberCorrected: $json['AddressNumberCorrected'] as bool?,
    businessChains: ($json['BusinessChains'] as List?)
        ?.nonNulls
        .map((e) => BusinessChain.fromJson(e as Map<String, dynamic>))
        .toList(),
    categories: ($json['Categories'] as List?)
        ?.nonNulls
        .map((e) => Category.fromJson(e as Map<String, dynamic>))
        .toList(),
    contacts: $json['Contacts'] != null
        ? Contacts.fromJson($json['Contacts'] as Map<String, dynamic>)
        : null,
    foodTypes: ($json['FoodTypes'] as List?)
        ?.nonNulls
        .map((e) => FoodType.fromJson(e as Map<String, dynamic>))
        .toList(),
    mainAddress: $json['MainAddress'] != null
        ? RelatedPlace.fromJson($json['MainAddress'] as Map<String, dynamic>)
        : null,
    mapView: ($json['MapView'] as List?)
        ?.nonNulls
        .map((e) => e as double)
        .toList(),
    openingHours: ($json['OpeningHours'] as List?)
        ?.nonNulls
        .map((e) => OpeningHours.fromJson(e as Map<String, dynamic>))
        .toList(),
    phonemes: $json['Phonemes'] != null
        ? PhonemeDetails.fromJson($json['Phonemes'] as Map<String, dynamic>)
        : null,
    politicalView: $json['PoliticalView'] as String?,
    position: ($json['Position'] as List?)
        ?.nonNulls
        .map((e) => e as double)
        .toList(),
    postalCodeDetails: ($json['PostalCodeDetails'] as List?)
        ?.nonNulls
        .map((e) => PostalCodeDetails.fromJson(e as Map<String, dynamic>))
        .toList(),
    secondaryAddresses: ($json['SecondaryAddresses'] as List?)
        ?.nonNulls
        .map((e) => RelatedPlace.fromJson(e as Map<String, dynamic>))
        .toList(),
    timeZone: $json['TimeZone'] != null
        ? TimeZone.fromJson($json['TimeZone'] as Map<String, dynamic>)
        : null,
    pricingBucket: _s.extractHeaderStringValue(
        response.headers, 'x-amz-geo-pricing-bucket')!,
  );
}