Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.p3group.bmw.chargenowlibrary
- import kotlinx.coroutines.flow.Flow
- /**
- * Provides connectivity to the ChargeNow service.
- */
- interface ChargeNowService {
- /**
- * Attempt to reserve a charging station for a specified [duration].
- * @param duration Duration of the reservation.
- * @param vin Vehicle identification number.
- * @param poiId Id of the charging station.
- * @return A [Flow] of [Reservation] which should offer the reservation status every minute.
- * @throws ChargeNowServiceException.ConnectionError if the ChargeNow application is not installed or if there was a problem with the connection.
- * @throws ChargeNowServiceException.ReservationError if ChargeNow encountered an error during the reservation process.
- */
- @Throws(ChargeNowServiceException.ReservationError::class, ChargeNowServiceException.ConnectionError::class)
- fun reservePoi(duration: Int, vin: String, poiId: String): Flow<Reservation>
- /**
- * Stop the reservation if the destination is reached or if you want to cancel the reservation.
- * @param vin Vehicle identification number.
- * @param poiId Id of the charging station.
- * @throws ChargeNowServiceException.ConnectionError if the ChargeNow application is not installed or if there was a problem with the connection.
- * @throws ChargeNowServiceException.ReservationError if ChargeNow encountered an error during the cancel reservation process.
- */
- @Throws(ChargeNowServiceException.ReservationError::class, ChargeNowServiceException.ConnectionError::class)
- suspend fun stopReservation(vin: String, poiId: String)
- /**
- * Returns the list of 20 charging stations based on current location and vin.
- * @throws ChargeNowServiceException.ConnectionError if the ChargeNow application is not installed or if there was a problem with the connection.
- * @throws ChargeNowServiceException.GetPoiListError if ChargeNow encountered an error while loading charging stations.
- */
- @Throws(ChargeNowServiceException.GetPoiListError::class, ChargeNowServiceException.ConnectionError::class)
- suspend fun getPoiList(vin: String, latitude: Double, longitude: Double): List<PointOfInterest>
- /**
- * Start charging.
- * @throws ChargeNowServiceException.ConnectionError if the ChargeNow application is not installed or if there was a problem with the connection.
- * @throws ChargeNowServiceException.ChargeError if ChargeNow encountered an error while starting the charge process.
- */
- suspend fun startCharging(vin: String, poiId: String)
- /**
- * Stop charging.
- * @throws ChargeNowServiceException.ConnectionError if the ChargeNow application is not installed or if there was a problem with the connection.
- * @throws ChargeNowServiceException.ChargeError if ChargeNow encountered an error while stopping the charge process.
- */
- suspend fun stopCharging(vin: String, poiId: String)
- /**
- * Checks if the user is logged in the ChargeNow app. If not, the charge now app will be opened to the login flow, then returned to this application.
- * @throws ChargeNowServiceException.ConnectionError if the ChargeNow application is not installed or if there was a problem with the connection.
- * @throws ChargeNowServiceException.LoginError if the login fails or the user stops the login process.
- */
- @Throws(ChargeNowServiceException.LoginError::class, ChargeNowServiceException.ConnectionError::class)
- suspend fun ensureLogin()
- /**
- * Checks if ChargeNow app is installed on the device.
- */
- fun isServiceAvailable(): Boolean
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement