using System;
using System.Threading.Tasks;
using TINK.Repository.Request;
using TINK.Model.User.Account;
using TINK.Model.Device;
using System.Collections.Generic;
using TINK.Model.MiniSurvey;
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.
/// Bike to return.
/// Geolocation of lock when returning bike.
/// Provides info about hard and software.
Task DoReturn(Bikes.Bike.BluetoothLock.IBikeInfoMutable bike, LocationDto geolocation = null, 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 p_oSender, LoginStateChangedEventArgs p_oEventArgs);
#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 p_strSessionCookie, string p_strMail)
{
SessionCookie = p_strSessionCookie;
Mail = p_strMail;
}
public string SessionCookie { get; }
public string Mail { get; }
}
}