using System; using System.Threading.Tasks; using TINK.Repository.Request; using TINK.Model.User.Account; using TINK.Model.Device; using System.Collections.Generic; 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 bike); /// Request to cancel a reservation. /// Bike to book. Task DoCancelReservation(Bikes.Bike.BC.IBikeInfoMutable bike); /// Get authentication keys to connect to lock. /// Bike to book. Task CalculateAuthKeys(Bikes.Bike.BluetoothLock.IBikeInfoMutable bike); /// Notifies COPRI about start of returning sequence. /// Operator specific call. /// Bike to return. /// Response on notification about start of returning sequence. Task StartReturningBike(Bikes.Bike.BC.IBikeInfoMutable bike); /// Updates COPRI lock state for a booked bike. /// 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.BC.IBikeInfoMutable bike); /// Request to book a bike and open its lock. /// Bike to book and to open lock for. Task BookAndOpenAync(Bikes.Bike.CopriLock.IBikeInfoMutable bike); /// Request to open lock. /// Bike for which lock has to be opened. Task OpenLockAsync(Bikes.Bike.CopriLock.IBikeInfoMutable bike); /// Request to close lock. /// Bike for which lock has to be closed. Task CloseLockAsync(Bikes.Bike.CopriLock.IBikeInfoMutable bike); /// Request to return a bike. /// Bike to return. /// Geolocation of lock when returning bike. /// Provides info about hard and software. Task DoReturn(Bikes.Bike.BC.IBikeInfoMutable bike, LocationDto geolocation = null, ISmartDevice smartDevice = null); /// Request to return bike and close the lock. /// Bike to return. /// Provides info about hard and software. Task ReturnAndCloseAsync(Bikes.Bike.CopriLock.IBikeInfoMutable bike, ISmartDevice smartDevice = 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); /// Submits mini survey to copri server. /// Collection of answers. Task DoSubmitMiniSurvey(IDictionary answers); #if USCSHARP9 /// /// Feedback given by user when returning bike. /// public interface IUserFeedback { /// Id of the bike to which the feedback is related to. string BikeId { get; } /// /// Holds whether bike is broken or not. /// bool IsBikeBroken { get; } /// /// Holds either /// - general feedback /// - error description of broken bike /// or both. /// string Message { get; } } #endif } /// 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 sender, LoginStateChangedEventArgs eventArgs); #if !USCSHARP9 /// /// Feedback given by user when returning bike. /// public interface IUserFeedback { /// Id of the bike to which the feedback is related to. string BikeId { get; } /// /// Holds whether bike is broken or not. /// bool IsBikeBroken { get; } /// /// Holds either /// - general feedback /// - error description of broken bike /// or both. /// string Message { get; } } #endif /// Event arguments to notify about changes of logged in state. public class LoginStateChangedEventArgs : EventArgs { public LoginStateChangedEventArgs() : this(string.Empty, string.Empty) { } public LoginStateChangedEventArgs(string sessionCookie, string mail) { SessionCookie = sessionCookie; Mail = mail; } public string SessionCookie { get; } public string Mail { get; } } }