mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2024-11-13 22:06:29 +01:00
177 lines
6.3 KiB
C#
177 lines
6.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
using TINK.Model.Device;
|
|
using TINK.Model.User.Account;
|
|
using TINK.Repository.Request;
|
|
|
|
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="bike">Bike to book.</param>
|
|
Task DoReserve(Bikes.BikeInfoNS.BC.IBikeInfoMutable bike);
|
|
|
|
/// <summary> Request to cancel a reservation.</summary>
|
|
/// <param name="bike">Bike to book.</param>
|
|
Task DoCancelReservation(Bikes.BikeInfoNS.BC.IBikeInfoMutable bike);
|
|
|
|
/// <summary> Get authentication keys to connect to lock.</summary>
|
|
/// <param name="bike">Bike to book.</param>
|
|
Task CalculateAuthKeys(Bikes.BikeInfoNS.BluetoothLock.IBikeInfoMutable bike);
|
|
|
|
/// <summary> Notifies COPRI about start of returning sequence. </summary>
|
|
/// <remarks> Operator specific call.</remarks>
|
|
/// <param name="bike">Bike to return.</param>
|
|
/// <returns>Response on notification about start of returning sequence.</returns>
|
|
Task StartReturningBike(Bikes.BikeInfoNS.BC.IBikeInfoMutable bike);
|
|
|
|
/// <summary> Updates COPRI lock state for a booked bike. </summary>
|
|
/// <param name="bike">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.BikeInfoNS.BluetoothLock.IBikeInfoMutable bike, LocationDto location = null);
|
|
|
|
/// <summary> Request to book a bike.</summary>
|
|
/// <param name="bike">Bike to book.</param>
|
|
/// <param name="nextAction">If not null next locking action which is performed after booking.</param>
|
|
Task DoBookAsync(Bikes.BikeInfoNS.BC.IBikeInfoMutable bike, LockingAction? nextAction = null);
|
|
|
|
/// <summary> Request to book a bike and open its lock.</summary>
|
|
/// <param name="bike">Bike to book and to open lock for.</param>
|
|
Task BookAndOpenAync(Bikes.BikeInfoNS.CopriLock.IBikeInfoMutable bike);
|
|
|
|
/// <summary> Request to open lock.</summary>
|
|
/// <param name="bike">Bike for which lock has to be opened.</param>
|
|
Task OpenLockAsync(Bikes.BikeInfoNS.CopriLock.IBikeInfoMutable bike);
|
|
|
|
/// <summary> Request to close lock.</summary>
|
|
/// <param name="bike">Bike for which lock has to be closed.</param>
|
|
Task CloseLockAsync(Bikes.BikeInfoNS.CopriLock.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<BookingFinishedModel> DoReturn(Bikes.BikeInfoNS.BC.IBikeInfoMutable bike, LocationDto geolocation = null, ISmartDevice smartDevice = null);
|
|
|
|
/// <summary> Request to return bike and close the lock.</summary>
|
|
/// <param name="bike">Bike to return.</param>
|
|
/// <param name="smartDevice">Provides info about hard and software.</param>
|
|
Task<BookingFinishedModel> ReturnAndCloseAsync(Bikes.BikeInfoNS.CopriLock.IBikeInfoMutable bike, 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; }
|
|
|
|
/// <summary> Submits feedback for a renting operation.</summary>
|
|
Task DoSubmitFeedback(
|
|
IUserFeedback userFeedback,
|
|
Uri opertorUri);
|
|
|
|
/// <summary> Submits mini survey to copri server. </summary>
|
|
/// <param name="answers">Collection of answers.</param>
|
|
Task DoSubmitMiniSurvey(IDictionary<string, string> answers);
|
|
|
|
#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="eventArgs">Holds session cookie and mail address if user logged in successfully.</param>
|
|
public delegate void LoginStateChangedEventHandler(object sender, LoginStateChangedEventArgs eventArgs);
|
|
|
|
#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 the current charging level of the battery in bars, null if unknown.
|
|
/// </summary>
|
|
int? CurrentChargeBars { get; set; }
|
|
|
|
/// <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 sessionCookie, string mail)
|
|
{
|
|
SessionCookie = sessionCookie;
|
|
Mail = mail;
|
|
}
|
|
|
|
public string SessionCookie { get; }
|
|
|
|
public string Mail { get; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Describes a action to be performed with an lock.
|
|
/// </summary>
|
|
public enum LockingAction
|
|
{
|
|
Close,
|
|
Open,
|
|
}
|
|
|
|
}
|