using System; using System.Threading.Tasks; using TINK.Model.Repository.Request; using TINK.Model.User.Account; namespace TINK.Model.Connector { public interface ICommand { /// Is raised whenever login state has changed. event LoginStateChangedEventHandler LoginStateChanged; /// /// Logs user in. /// If log in succeeds either and session might be updated if it was no more valid (logged in by an different device). /// If log in fails (password modified) session cookie is set to empty. /// If communication fails an exception is thrown. /// Task DoLogin(string p_strMail, string p_strPassword, string p_strDeviceId); /// Logs user out. Task DoLogout(); /// Request to reserve a bike. /// Bike to book. Task DoReserve(Bikes.Bike.BC.IBikeInfoMutable p_oBike); /// Request to cancel a reservation. /// Bike to book. Task DoCancelReservation(Bikes.Bike.BC.IBikeInfoMutable p_oBike); /// Get authentication keys to connect to lock. /// Bike to book. Task CalculateAuthKeys(Bikes.Bike.BluetoothLock.IBikeInfoMutable bike); /// Updates COPRI lock state for a booked bike. /// Id of the bike to update locking state for. /// Geolocation of lock when returning bike. /// Response on updating locking state. Task UpdateLockingStateAsync(Bikes.Bike.BluetoothLock.IBikeInfoMutable bike, LocationDto location = null); /// Request to book a bike. /// Bike to book. Task DoBook(Bikes.Bike.BluetoothLock.IBikeInfoMutable bike); /// Request to return a bike. /// Geolocation of lock when returning bike. /// Bike to return. Task DoReturn(Bikes.Bike.BluetoothLock.IBikeInfoMutable bike, LocationDto geolocation = null); /// True if connector has access to copri server, false if cached values are used. bool IsConnected { get; } /// True if user is logged in false if not. string SessionCookie { get; } Task DoSubmitFeedback(IUserFeedback userFeedback, Uri opertorUri); /// /// Feedback given by user when returning bike. /// public interface IUserFeedback { /// /// Holds whether bike is broken or not. /// bool IsBikeBroken { get; } /// /// Holds either /// - general feedback /// - error description of broken bike /// or both. /// string Message { get; } } } /// Defines delegate to be raised whenever login state changes. /// Holds session cookie and mail address if user logged in successfully. public delegate void LoginStateChangedEventHandler(object p_oSender, LoginStateChangedEventArgs p_oEventArgs); /// Event arguments to notify about changes of logged in state. public class LoginStateChangedEventArgs : EventArgs { public LoginStateChangedEventArgs() : this(string.Empty, string.Empty) { } public LoginStateChangedEventArgs(string p_strSessionCookie, string p_strMail) { SessionCookie = p_strSessionCookie; Mail = p_strMail; } public string SessionCookie { get; } public string Mail { get; } } }