using System; using System.Threading.Tasks; using TINK.Model.Device; using TINK.Repository.Request; using TINK.Repository.Response; namespace TINK.Repository { /// <summary> Interface to communicate with copri server.</summary> public interface ICopriServerBase { /// <summary> Logs user in. </summary> /// <param name="mailAddress">Mailaddress of user to log in.</param> /// <param name="password">Password to log in.</param> /// <param name="deviceId">Id specifying user and hardware.</param> /// <remarks>Response which holds auth cookie <see cref="ResponseBase.authcookie"/></remarks> Task<AuthorizationResponse> DoAuthorizationAsync( string mailAddress, string password, string deviceId); /// <summary> Logs user out. </summary> /// <remarks>Response which holds auth cookie <see cref="ResponseBase.authcookie"/></remarks> Task<AuthorizationoutResponse> DoAuthoutAsync(); /// <summary> Reserves bike. </summary> /// <param name="bikeId">Id of the bike to reserve.</param> /// <param name="operatorUri">Holds the uri of the operator or null, in case of single operator setup.</param> /// <returns>Response on reserving request.</returns> Task<ReservationBookingResponse> DoReserveAsync( string bikeId, Uri operatorUri); /// <summary> Cancels reservation of bik. </summary> /// <param name="bikeId">Id of the bike to reserve.</param> /// <param name="operatorUri">Holds the uri of the operator or null, in case of single operator setup.</param> /// <returns>Response on cancel reservation request.</returns> Task<ReservationCancelReturnResponse> DoCancelReservationAsync( string bikeId, Uri operatorUri); /// <summary> Get authentication keys. </summary> /// <param name="bikeId">Id of the bike to get keys for.</param> /// <param name="operatorUri">Holds the uri of the operator or null, in case of single operator setup.</param> /// <returns>Response holding authentication keys.</returns> Task<ReservationBookingResponse> CalculateAuthKeysAsync( string bikeId, Uri operatorUri); /// <summary> Updates COPRI lock state for a booked bike. </summary> /// <param name="bikeId">Id of the bike to update locking state for.</param> /// <param name="location">Geolocation of lock.</param> /// <param name="state">New locking state.</param> /// <param name="batteryPercentage">Holds the filling level percentage of the battery.</param> /// <param name="operatorUri">Holds the uri of the operator or null, in case of single operator setup.</param> /// <returns>Response on updating locking state.</returns> Task<ReservationBookingResponse> UpdateLockingStateAsync( string bikeId, LocationDto location, lock_state state, double batteryPercentage, Uri operatorUri); /// <summary> Books a bike. </summary> /// <param name="bikeId">Id of the bike to book.</param> /// <param name="guid">Used to publish GUID from app to copri. Used for initial setup of bike in copri.</param> /// <param name="batteryPercentage">Holds the filling level percentage of the battery.</param> /// <param name="operatorUri">Holds the uri of the operator or null, in case of single operator setup.</param> /// <returns>Response on booking request.</returns> Task<ReservationBookingResponse> DoBookAsync( string bikeId, Guid guid, double batteryPercentage, Uri operatorUri); /// <summary> Returns a bike. </summary> /// <param name="bikeId">Id of the bike to return.</param> /// <param name="location">Geolocation of lock.</param> /// <param name="smartDevice">Provides info about hard and software.</param> /// <param name="operatorUri">Holds the uri of the operator or null, in case of single operator setup.</param> /// <returns>Response on returning request.</returns> Task<ReservationCancelReturnResponse> DoReturn( string bikeId, LocationDto location, ISmartDevice smartDevice, Uri operatorUri); /// <summary> /// Submits feedback to copri server. /// </summary> /// <param name="bikeId">Id of the bike to submit feedback for.</param> /// <param name="isBikeBroken">True if bike is broken.</param> /// <param name="message">General purpose message or error description.</param> Task<SubmitFeedbackResponse> DoSubmitFeedback( string bikeId, string message, bool isBikeBroken, Uri operatorUri); /// <summary> True if connector has access to copri server, false if cached values are used. </summary> bool IsConnected { get; } /// <summary> Gets the session cookie if user is logged in, an empty string otherwise. </summary> string SessionCookie { get; } /// <summary> Holds the id of the merchant. </summary> string MerchantId { get; } } /// <summary> Interface to communicate with copri server.</summary> public interface ICopriServer : ICopriServerBase { /// <summary> Get list of stations. </summary> /// <returns>List of all stations.</returns> Task<StationsAllResponse> GetStationsAsync(); /// <summary> Gets a list of bikes from Copri. </summary> /// <returns>Response holding list of bikes.</returns> Task<BikesAvailableResponse> GetBikesAvailableAsync(); /// <summary> Gets a list of bikes reserved/ booked by acctive user from Copri.</summary> /// <returns>Response holding list of bikes.</returns> Task<BikesReservedOccupiedResponse> GetBikesOccupiedAsync(); } }