PlacesClient

public interface PlacesClient


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

Summary

Public methods

abstract Task<FetchPhotoResponse>

Fetches a photo.

abstract Task<FetchPlaceResponse>

Fetches the details of a place.

abstract Task<FetchResolvedPhotoUriResponse>

Fetches a resolved uri for the photo.

abstract Task<FindAutocompletePredictionsResponse>

Fetches autocomplete predictions.

abstract Task<FindCurrentPlaceResponse>

Fetches the approximate current location of the user's device.

abstract Task<IsOpenResponse>

Returns whether or not a place is open, fetching any place info using fetchPlace (if necessary).

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 FetchPhotoResponse

Wraps PlacesClient.fetchPhoto in a suspending function.

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

Wraps PlacesClient.fetchPlace in a suspending function.

default final @NonNull FetchResolvedPhotoUriResponse

Wraps PlacesClient.fetchResolvedPhotoUri in a suspending function.

default final @NonNull FindAutocompletePredictionsResponse

Wraps PlacesClient.findAutocompletePredictions in a suspending function.

default final @NonNull FindCurrentPlaceResponse
@RequiresPermission(anyOf = ["ACCESS_COARSE_LOCATION", "ACCESS_FINE_LOCATION"])
PlacesClientKt.awaitFindCurrentPlace(
    @NonNull PlacesClient receiver,
    @NonNull List<@NonNull Place.Field> placeFields
)

Wraps PlacesClient.findCurrentPlace 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.BuilderUnit> 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.BuilderUnit> actions
)

Wraps PlacesClient.searchNearby in a suspending function.

Public methods

fetchPhoto

abstract Task<FetchPhotoResponsefetchPhoto(FetchPhotoRequest request)

Fetches a photo.

The photos service may cache the image data. If the requested photo does not exist in the cache then a network lookup will be performed.

Parameters
FetchPhotoRequest request

The request specifying the photo to request.

Returns
Task<FetchPhotoResponse>

response containing the photo requested or an if an error occurred.

fetchPlace

abstract Task<FetchPlaceResponsefetchPlace(FetchPlaceRequest request)

Fetches the details of a place.

Parameters
FetchPlaceRequest request

The request specifying the place of interest.

Returns
Task<FetchPlaceResponse>

Response containing the place of interest or an if an error occurred.

fetchResolvedPhotoUri

abstract Task<FetchResolvedPhotoUriResponsefetchResolvedPhotoUri(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>

response containing the photo uri requested or an if an error occurred.

findAutocompletePredictions

abstract Task<FindAutocompletePredictionsResponsefindAutocompletePredictions(
    FindAutocompletePredictionsRequest request
)

Fetches autocomplete predictions.

Parameters
FindAutocompletePredictionsRequest request

The request specifying details of the autocomplete query.

Returns
Task<FindAutocompletePredictionsResponse>

Response containing the list of prediction objects or an if an error occurred.

findCurrentPlace

@RequiresPermission(anyOf = )
abstract Task<FindCurrentPlaceResponsefindCurrentPlace(FindCurrentPlaceRequest request)

Fetches the approximate current location of the user's device.

The device must have Location Services enabled, and the app must have the following permissions granted.

Calling this method without granting this permission in the manifest will result in a being thrown.

This API assumes Fused Location Provider is available on the device, in order to retrieve it's current location.

Parameters
FindCurrentPlaceRequest request

the request specifying filtering details.

Returns
Task<FindCurrentPlaceResponse>

response containing the user's current place candidates or an if an error occurred.

isOpen

abstract Task<IsOpenResponseisOpen(IsOpenRequest request)

Returns whether or not a place is open, fetching any place info using fetchPlace (if necessary).

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:

Parameters
IsOpenRequest request

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

Returns
Task<IsOpenResponse>

Response on whether the place of interest is open or an if an error occurred.

searchByText

abstract Task<SearchByTextResponsesearchByText(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>

Response containing the place(s) of interest or an if an error occurred.

searchNearby

abstract Task<SearchNearbyResponsesearchNearby(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>

Response containing the place(s) of interest or an if an error occurred.

Extension functions

PlacesClientKt.awaitFetchPhoto

default final @NonNull FetchPhotoResponse PlacesClientKt.awaitFetchPhoto(
    @NonNull PlacesClient receiver,
    @NonNull PhotoMetadata photoMetadata,
    @ExtensionFunctionType @NonNull Function1<@NonNull FetchPhotoRequest.BuilderUnit> actions
)

Wraps PlacesClient.fetchPhoto in a suspending function.

Fetches a photo. If an error occurred, an ApiException will be thrown.

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.BuilderUnit> 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.BuilderUnit> 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.BuilderUnit> actions
)

Wraps PlacesClient.findAutocompletePredictions in a suspending function.

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

PlacesClientKt.awaitFindCurrentPlace

@RequiresPermission(anyOf = ["ACCESS_COARSE_LOCATION", "ACCESS_FINE_LOCATION"])
default final @NonNull FindCurrentPlaceResponse PlacesClientKt.awaitFindCurrentPlace(
    @NonNull PlacesClient receiver,
    @NonNull List<@NonNull Place.Field> placeFields
)

Wraps PlacesClient.findCurrentPlace in a suspending function.

Fetches the approximate current place of the user's device. Calling this method without granting the appropriate permissions will result in a SecurityException being thrown. In addition, if an error occurred while fetching the current place, 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.BuilderUnit> 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.BuilderUnit> 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.