Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2020
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.62 KB | None | 0 0
  1. package com.p3group.bmw.chargenowlibrary
  2.  
  3. import kotlinx.coroutines.flow.Flow
  4.  
  5. /**
  6. * Provides connectivity to the ChargeNow service.
  7. */
  8. interface ChargeNowService {
  9.  
  10. /**
  11. * Attempt to reserve a charging station for a specified [duration].
  12. * @param duration Duration of the reservation.
  13. * @param vin Vehicle identification number.
  14. * @param poiId Id of the charging station.
  15. * @return A [Flow] of [Reservation] which should offer the reservation status every minute.
  16. * @throws ChargeNowServiceException.ConnectionError if the ChargeNow application is not installed or if there was a problem with the connection.
  17. * @throws ChargeNowServiceException.ReservationError if ChargeNow encountered an error during the reservation process.
  18. */
  19. @Throws(ChargeNowServiceException.ReservationError::class, ChargeNowServiceException.ConnectionError::class)
  20. fun reservePoi(duration: Int, vin: String, poiId: String): Flow<Reservation>
  21.  
  22. /**
  23. * Stop the reservation if the destination is reached or if you want to cancel the reservation.
  24. * @param vin Vehicle identification number.
  25. * @param poiId Id of the charging station.
  26. * @throws ChargeNowServiceException.ConnectionError if the ChargeNow application is not installed or if there was a problem with the connection.
  27. * @throws ChargeNowServiceException.ReservationError if ChargeNow encountered an error during the cancel reservation process.
  28. */
  29. @Throws(ChargeNowServiceException.ReservationError::class, ChargeNowServiceException.ConnectionError::class)
  30. suspend fun stopReservation(vin: String, poiId: String)
  31.  
  32. /**
  33. * Returns the list of 20 charging stations based on current location and vin.
  34. * @throws ChargeNowServiceException.ConnectionError if the ChargeNow application is not installed or if there was a problem with the connection.
  35. * @throws ChargeNowServiceException.GetPoiListError if ChargeNow encountered an error while loading charging stations.
  36. */
  37. @Throws(ChargeNowServiceException.GetPoiListError::class, ChargeNowServiceException.ConnectionError::class)
  38. suspend fun getPoiList(vin: String, latitude: Double, longitude: Double): List<PointOfInterest>
  39.  
  40. /**
  41. * Start charging.
  42. * @throws ChargeNowServiceException.ConnectionError if the ChargeNow application is not installed or if there was a problem with the connection.
  43. * @throws ChargeNowServiceException.ChargeError if ChargeNow encountered an error while starting the charge process.
  44. */
  45. suspend fun startCharging(vin: String, poiId: String)
  46.  
  47. /**
  48. * Stop charging.
  49. * @throws ChargeNowServiceException.ConnectionError if the ChargeNow application is not installed or if there was a problem with the connection.
  50. * @throws ChargeNowServiceException.ChargeError if ChargeNow encountered an error while stopping the charge process.
  51. */
  52. suspend fun stopCharging(vin: String, poiId: String)
  53.  
  54. /**
  55. * 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.
  56. * @throws ChargeNowServiceException.ConnectionError if the ChargeNow application is not installed or if there was a problem with the connection.
  57. * @throws ChargeNowServiceException.LoginError if the login fails or the user stops the login process.
  58. */
  59. @Throws(ChargeNowServiceException.LoginError::class, ChargeNowServiceException.ConnectionError::class)
  60. suspend fun ensureLogin()
  61.  
  62. /**
  63. * Checks if ChargeNow app is installed on the device.
  64. */
  65. fun isServiceAvailable(): Boolean
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement