mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2024-11-16 15:16:34 +01:00
129 lines
4.8 KiB
C#
129 lines
4.8 KiB
C#
using System;
|
|
using System.Threading.Tasks;
|
|
using TINK.Repository.Request;
|
|
using TINK.Model.User.Account;
|
|
using TINK.Model.Device;
|
|
|
|
namespace TINK.Model.Connector
|
|
{
|
|
public interface ICommand
|
|
{
|
|
/// <summary> Is raised whenever login state has changed.</summary>
|
|
event LoginStateChangedEventHandler LoginStateChanged;
|
|
|
|
/// <summary>
|
|
/// 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.
|
|
/// </summary>
|
|
Task<IAccount> DoLogin(string p_strMail, string p_strPassword, string p_strDeviceId);
|
|
|
|
/// <summary> Logs user out. </summary>
|
|
Task DoLogout();
|
|
|
|
/// <summary> Request to reserve a bike.</summary>
|
|
/// <param name="p_oBike">Bike to book.</param>
|
|
Task DoReserve(Bikes.Bike.BC.IBikeInfoMutable p_oBike);
|
|
|
|
/// <summary> Request to cancel a reservation.</summary>
|
|
/// <param name="p_oBike">Bike to book.</param>
|
|
Task DoCancelReservation(Bikes.Bike.BC.IBikeInfoMutable p_oBike);
|
|
|
|
/// <summary> Get authentication keys to connect to lock.</summary>
|
|
/// <param name="bike">Bike to book.</param>
|
|
Task CalculateAuthKeys(Bikes.Bike.BluetoothLock.IBikeInfoMutable bike);
|
|
|
|
/// <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 when returning bike.</param>
|
|
/// <returns>Response on updating locking state.</returns>
|
|
Task UpdateLockingStateAsync(Bikes.Bike.BluetoothLock.IBikeInfoMutable bike, LocationDto location = null);
|
|
|
|
/// <summary> Request to book a bike.</summary>
|
|
/// <param name="bike">Bike to book.</param>
|
|
Task DoBook(Bikes.Bike.BluetoothLock.IBikeInfoMutable bike);
|
|
|
|
/// <summary> Request to return a bike.</summary>
|
|
/// <param name="bike">Bike to return.</param>
|
|
/// <param name="location">Geolocation of lock when returning bike.</param>
|
|
/// <param name="smartDevice">Provides info about hard and software.</param>
|
|
Task DoReturn(Bikes.Bike.BluetoothLock.IBikeInfoMutable bike, LocationDto geolocation = null, ISmartDevice smartDevice = null);
|
|
|
|
/// <summary> True if connector has access to copri server, false if cached values are used. </summary>
|
|
bool IsConnected { get; }
|
|
|
|
/// <summary> True if user is logged in false if not. </summary>
|
|
string SessionCookie { get; }
|
|
|
|
Task DoSubmitFeedback(IUserFeedback userFeedback, Uri opertorUri);
|
|
#if USCSHARP9
|
|
/// <summary>
|
|
/// Feedback given by user when returning bike.
|
|
/// </summary>
|
|
public interface IUserFeedback
|
|
{
|
|
/// <summary> Id of the bike to which the feedback is related to.</summary>
|
|
string BikeId { get; }
|
|
|
|
/// <summary>
|
|
/// Holds whether bike is broken or not.
|
|
/// </summary>
|
|
bool IsBikeBroken { get; }
|
|
|
|
/// <summary>
|
|
/// Holds either
|
|
/// - general feedback
|
|
/// - error description of broken bike
|
|
/// or both.
|
|
/// </summary>
|
|
string Message { get; }
|
|
}
|
|
#endif
|
|
}
|
|
|
|
/// <summary>Defines delegate to be raised whenever login state changes.</summary>
|
|
/// <param name="p_oEventArgs">Holds session cookie and mail address if user logged in successfully.</param>
|
|
public delegate void LoginStateChangedEventHandler(object p_oSender, LoginStateChangedEventArgs p_oEventArgs);
|
|
|
|
#if !USCSHARP9
|
|
/// <summary>
|
|
/// Feedback given by user when returning bike.
|
|
/// </summary>
|
|
public interface IUserFeedback
|
|
{
|
|
/// <summary> Id of the bike to which the feedback is related to.</summary>
|
|
string BikeId { get; }
|
|
|
|
/// <summary>
|
|
/// Holds whether bike is broken or not.
|
|
/// </summary>
|
|
bool IsBikeBroken { get; }
|
|
|
|
/// <summary>
|
|
/// Holds either
|
|
/// - general feedback
|
|
/// - error description of broken bike
|
|
/// or both.
|
|
/// </summary>
|
|
string Message { get; }
|
|
}
|
|
#endif
|
|
|
|
/// <summary> Event arguments to notify about changes of logged in state.</summary>
|
|
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; }
|
|
}
|
|
}
|