PlacesClient

public interface PlacesClient


Client that exposes the Places API methods. To get a PlacesClient, use createClient.

Summary

Public methods

abstract Task<FetchPlaceResponse>

Fetches the details of a place.

abstract Task<FetchResolvedPhotoUriResponse>

This method is deprecated.

Update your code to use the Place Details component in Places UI Kit, which provides a pre-built UI to display place details including photos and reviews that automatically handles required attributions.

abstract Task<FindAutocompletePredictionsResponse>

Fetches autocomplete predictions.

abstract Task<IsOpenResponse>

Returns whether or not a place is open.

abstract Task<SearchByTextResponse>

Search for place(s) of interest using a text query.

abstract Task<SearchNearbyResponse>

Search for place(s) of interest using a location.

Extension functions

default final @NonNull FetchPlaceResponse
PlacesClientKt.awaitFetchPlace(
    @NonNull PlacesClient receiver,
    @NonNull String placeId,
    @NonNull List<@NonNull Place.Field> placeFields,
    @ExtensionFunctionType @NonNull Function1<@NonNull FetchPlaceRequest.Builder, Unit> actions
)

Wraps PlacesClient.fetchPlace in a suspending function.

default final @NonNull FetchResolvedPhotoUriResponse

This method is deprecated. Update your code to use the Place Details component in Places UI Kit, which provides a prebuilt UI to display place details including photos and reviews that automatically handles required attributions.

default final @NonNull FindAutocompletePredictionsResponse

Wraps PlacesClient.findAutocompletePredictions in a suspending function.

default final @NonNull IsOpenResponse
PlacesClientKt.awaitIsOpen(
    @NonNull PlacesClient receiver,
    @NonNull String placeId,
    Long utcTimeMillis
)

Wraps PlacesClient.isOpen in a suspending function with the given placeId.

default final @NonNull IsOpenResponse
PlacesClientKt.awaitIsOpen(
    @NonNull PlacesClient receiver,
    @NonNull Place place,
    Long utcTimeMillis
)

Wraps PlacesClient.isOpen in a suspending function with the given Place object.

default final @NonNull SearchByTextResponse
PlacesClientKt.awaitSearchByText(
    @NonNull PlacesClient receiver,
    @NonNull String textQuery,
    @NonNull List<@NonNull Place.Field> placeFields,
    @ExtensionFunctionType @NonNull Function1<@NonNull SearchByTextRequest.Builder, Unit> actions
)

Wraps PlacesClient.searchByText in a suspending function.

default final @NonNull SearchNearbyResponse
PlacesClientKt.awaitSearchNearby(
    @NonNull PlacesClient receiver,
    @NonNull LocationRestriction locationRestriction,
    @NonNull List<@NonNull Place.Field> placeFields,
    @ExtensionFunctionType @NonNull Function1<@NonNull SearchNearbyRequest.Builder, Unit> actions
)

Wraps PlacesClient.searchNearby in a suspending function.

Public methods

fetchPlace

abstract Task<FetchPlaceResponse> fetchPlace(FetchPlaceRequest request)

Fetches the details of a place.

Parameters
FetchPlaceRequest request

The request specifying the place of interest.

Returns
Task<FetchPlaceResponse>

a response containing the place of interest, as a Place object. However, if an error occurred, an com.google.android.gms.common.api.ApiException will be returned instead.

fetchResolvedPhotoUri

abstract Task<FetchResolvedPhotoUriResponse> fetchResolvedPhotoUri(FetchResolvedPhotoUriRequest request)

Fetches a resolved uri for the photo. Resolving the URI (that is, calling this method) causes the Place Photo SKU to be charged, so it is generally recommended to avoid calling this function for photos that will not be displayed.

FetchResolvedPhotoUri is only supported by Places API (New). Please enable your API key for the Places API (New) in the Google Cloud Console to access this service.

Parameters
FetchResolvedPhotoUriRequest request

The request specifying the photo to request.

Returns
Task<FetchResolvedPhotoUriResponse>

a response that contains the photo uri requested. However, if an error occurred, an com.google.android.gms.common.api.ApiException will be returned instead.

findAutocompletePredictions

abstract Task<FindAutocompletePredictionsResponse> findAutocompletePredictions(
    FindAutocompletePredictionsRequest request
)

Fetches autocomplete predictions.

Parameters
FindAutocompletePredictionsRequest request

The request specifying details of the autocomplete query.

Returns
Task<FindAutocompletePredictionsResponse>

a response containing the list of prediction objects. However, if an error occurred, an com.google.android.gms.common.api.ApiException will be returned instead.

isOpen

abstract Task<IsOpenResponse> isOpen(IsOpenRequest request)

Returns whether or not a place is open.

If necessary, a fetchPlace request will be performed in order to gather the required info to make a determination.

Please note that for future dates and time, the open/closed status might not be accurate due to potential time zone adjustments (for example, daylight saving time changes) or business status changes.

If providing a Place object, ID is required, else an IllegalArgumentException will be thrown. If the following fields are not provided, a request will be made to fetch the info:

**NOTE:** It is best practice to check that opening hours are not null before passing in a Place (with opening hours already requested) to IsOpenRequest. In some cases, a place may not have any opening hours data available. If a place request with the opening hours field has already been made, and opening hours are null, calling this method using the place response object will result in another billable event.

Parameters
IsOpenRequest request

The request specifying the place information and time for if a place is open.

Returns
Task<IsOpenResponse>

a response on whether the place of interest is open. However, if an error occurred, an com.google.android.gms.common.api.ApiException will be returned instead.

searchByText

abstract Task<SearchByTextResponse> searchByText(SearchByTextRequest request)

Search for place(s) of interest using a text query.

SearchByText is only supported by Places API (New). Please enable your API key for the Places API (New) in the Google Cloud Console to access this service.

Parameters
SearchByTextRequest request

The request specifying the parameters for the search.

Returns
Task<SearchByTextResponse>

a response containing the place(s) of interest. However, if an error occurred, an com.google.android.gms.common.api.ApiException will be returned instead.

searchNearby

abstract Task<SearchNearbyResponse> searchNearby(SearchNearbyRequest request)

Search for place(s) of interest using a location.

SearchNearby is only supported by Places API (New). Please enable your API key for the Places API (New) in the Google Cloud Console to access this service.

Parameters
SearchNearbyRequest request

The request specifying the parameters for the search.

Returns
Task<SearchNearbyResponse>

a response containing the place(s) of interest. However, if an error occurred, an com.google.android.gms.common.api.ApiException will be returned instead.

Extension functions

PlacesClientKt.awaitFetchPlace

default final @NonNull FetchPlaceResponse PlacesClientKt.awaitFetchPlace(
    @NonNull PlacesClient receiver,
    @NonNull String placeId,
    @NonNull List<@NonNull Place.Field> placeFields,
    @ExtensionFunctionType @NonNull Function1<@NonNull FetchPlaceRequest.Builder, Unit> actions
)

Wraps PlacesClient.fetchPlace in a suspending function.

Fetches the details of a place. If an error occurred, an ApiException will be thrown.

PlacesClientKt.awaitFetchResolvedPhotoUri

default final @NonNull FetchResolvedPhotoUriResponse PlacesClientKt.awaitFetchResolvedPhotoUri(
    @NonNull PlacesClient receiver,
    @NonNull PhotoMetadata photoMetadata,
    @ExtensionFunctionType @NonNull Function1<@NonNull FetchResolvedPhotoUriRequest.Builder, Unit> actions
)

Wraps PlacesClient.fetchResolvedPhotoUri in a suspending function.

Fetches a resolved uri for the photo of a place. If an error occurred, an ApiException will be thrown.

PlacesClientKt.awaitFindAutocompletePredictions

default final @NonNull FindAutocompletePredictionsResponse PlacesClientKt.awaitFindAutocompletePredictions(
    @NonNull PlacesClient receiver,
    @ExtensionFunctionType @NonNull Function1<@NonNull FindAutocompletePredictionsRequest.Builder, Unit> actions
)

Wraps PlacesClient.findAutocompletePredictions in a suspending function.

Fetches autocomplete predictions. If an error occurred, an ApiException will be thrown.

PlacesClientKt.awaitIsOpen

default final @NonNull IsOpenResponse PlacesClientKt.awaitIsOpen(
    @NonNull PlacesClient receiver,
    @NonNull String placeId,
    Long utcTimeMillis
)

Wraps PlacesClient.isOpen in a suspending function with the given placeId.

Returns whether or not a place is open. If an error occurred, an ApiException will be thrown.

PlacesClientKt.awaitIsOpen

default final @NonNull IsOpenResponse PlacesClientKt.awaitIsOpen(
    @NonNull PlacesClient receiver,
    @NonNull Place place,
    Long utcTimeMillis
)

Wraps PlacesClient.isOpen in a suspending function with the given Place object.

Returns whether or not a place is open. If an error occurred, an ApiException will be thrown.

PlacesClientKt.awaitSearchByText

default final @NonNull SearchByTextResponse PlacesClientKt.awaitSearchByText(
    @NonNull PlacesClient receiver,
    @NonNull String textQuery,
    @NonNull List<@NonNull Place.Field> placeFields,
    @ExtensionFunctionType @NonNull Function1<@NonNull SearchByTextRequest.Builder, Unit> actions
)

Wraps PlacesClient.searchByText in a suspending function.

Fetches the place(s) of interest using a text query. If an error occurred, an ApiException will be thrown.

PlacesClientKt.awaitSearchNearby

default final @NonNull SearchNearbyResponse PlacesClientKt.awaitSearchNearby(
    @NonNull PlacesClient receiver,
    @NonNull LocationRestriction locationRestriction,
    @NonNull List<@NonNull Place.Field> placeFields,
    @ExtensionFunctionType @NonNull Function1<@NonNull SearchNearbyRequest.Builder, Unit> actions
)

Wraps PlacesClient.searchNearby in a suspending function.

Fetches the place(s) of interest using a location. If an error occurred, an ApiException will be thrown.