requestParkingAvailability

Requests the availability of a parking place.

The main parameter required is the ParkingDetailId of the parking place, which can be obtained from a search result or through a POI details request.

Note: This operation is synchronous and should not be executed on the main thread. Execution on the main thread will block the application and might throw an exception if it involves a network call

Usage Example:

// Initialize the ParkingDetailProvider
val parkingDetailProvider = ParkingDetailProviderImplementation(...)

// After obtaining the parkingDetailId from a search result or a POI details request,
// create options for the parking availability request
val options = searchResult.searchResultId.parkingDetailId?.let { parkingDetailId ->
ParkingAvailabilityOptions(parkingDetailId)
}

// Request parking availability
options?.let { options ->
val result = parkingDetailProvider.requestParkingAvailability(options)

if (result.isSuccess()) {
val response = result.value()
// Process the response.
Log.d(response.statuses.first().isAvailable)
Log.d(response.statuses.first().emptySpotsCount)
} else {
val failure = result.failure()
// Handle failure.
Log.d(failure.message)
}
}

Return

The Result containing a ParkingAvailabilityResponse if the call succeeds or a SearchFailure if it fails.

Parameters

options

Specifies the input of the request.


Requests the availability of a parking place.

The main parameter required is the ParkingDetailId of the parking place, which can be obtained from a search result or through a POI details request.

This is an asynchronous call, and the result will be returned through the provided callback.

Note: The callback is executed on the main thread. Usage example:

// Initialize the ParkingDetailProvider
val parkingDetailProvider = ParkingDetailProviderImplementation(...)

// After obtaining the parkingDetailId from a search result or a POI details request,
// create options for the parking availability request
val options = searchResult.searchResultId.parkingDetailId?.let { parkingDetailId ->
ParkingAvailabilityOptions(parkingDetailId)
}

// Create the callback
val callback = object : ParkingAvailabilityCallback {
override fun onSuccess(result: ParkingAvailabilityResponse) {
// Process the response.
Log.d(response.statuses.first().isAvailable)
Log.d(response.statuses.first().emptySpotsCount)
}

override fun onFailure(failure: SearchFailure) {
// Handle failure.
Log.d(failure.message)
}
}

// Request parking availability using the pre-created callback
options?.let { options ->
val cancellable = parkingDetailProvider.requestParkingAvailability(options, callback)

// You can cancel the operation if needed:
cancellable.cancel()
}

Return

A Cancellable object that stops the ongoing operation if needed if it hasn't been completed yet.

Parameters

options

Specifies the input of the request.

callback

The ParkingAvailabilityCallback invoked when the parking availability request operation has been finished either successfully or with an error. The callback will be executed in the main thread.