sharee.bike-App/TINKLib/Repository/ICopriServer.cs

170 lines
7.5 KiB
C#
Raw Normal View History

2022-09-20 13:51:55 +02:00
using System;
2021-08-01 17:24:15 +02:00
using System.Collections.Generic;
2021-05-13 20:03:07 +02:00
using System.Threading.Tasks;
2022-09-20 13:51:55 +02:00
using TINK.Model.Bikes.BikeInfoNS.BluetoothLock;
2022-12-27 21:08:09 +01:00
using TINK.Model.Connector;
2021-06-26 20:57:55 +02:00
using TINK.Model.Device;
using TINK.Repository.Request;
2021-05-13 20:03:07 +02:00
using TINK.Repository.Response;
2021-06-26 20:57:55 +02:00
namespace TINK.Repository
2021-05-13 20:03:07 +02:00
{
2022-09-06 16:08:19 +02:00
/// <summary> Interface to communicate with copri server.</summary>
public interface ICopriServerBase
{
/// <summary> Logs user in. </summary>
/// <param name="mailAddress">Mailaddress of user to log in.</param>
/// <param name="password">Password to log in.</param>
/// <param name="deviceId">Id specifying user and hardware.</param>
/// <remarks>Response which holds auth cookie <see cref="ResponseBase.authcookie"/></remarks>
Task<AuthorizationResponse> DoAuthorizationAsync(
string mailAddress,
string password,
string deviceId);
/// <summary> Logs user out. </summary>
/// <remarks>Response which holds auth cookie <see cref="ResponseBase.authcookie"/></remarks>
Task<AuthorizationoutResponse> DoAuthoutAsync();
/// <summary> Reserves bike. </summary>
/// <param name="bikeId">Id of the bike to reserve.</param>
/// <param name="operatorUri">Holds the uri of the operator or null, in case of single operator setup.</param>
/// <returns>Response on reserving request.</returns>
Task<ReservationBookingResponse> DoReserveAsync(
string bikeId,
Uri operatorUri);
/// <summary> Cancels reservation of bik. </summary>
/// <param name="bikeId">Id of the bike to reserve.</param>
/// <param name="operatorUri">Holds the uri of the operator or null, in case of single operator setup.</param>
/// <returns>Response on cancel reservation request.</returns>
Task<ReservationCancelReturnResponse> DoCancelReservationAsync(
string bikeId,
Uri operatorUri);
/// <summary> Get authentication keys. </summary>
/// <param name="bikeId">Id of the bike to get keys for.</param>
/// <param name="operatorUri">Holds the uri of the operator or null, in case of single operator setup.</param>
/// <returns>Response holding authentication keys.</returns>
Task<ReservationBookingResponse> CalculateAuthKeysAsync(
string bikeId,
Uri operatorUri);
/// <summary> Notifies COPRI about start of returning sequence. </summary>
/// <remarks> Operator specific call.</remarks>
/// <param name="bikeId">Id of the bike to return.</param>+
/// <param name="operatorUri">Holds the uri of the operator or null, in case of single operator setup.</param>
/// <returns>Response on notification about start of returning sequence.</returns>
Task<ResponseBase> StartReturningBike(
string bikeId,
Uri operatorUri);
/// <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.</param>
/// <param name="state">New locking state.</param>
/// <param name="batteryPercentage">Holds the filling level percentage of the battery.</param>
/// <param name="operatorUri">Holds the uri of the operator or null, in case of single operator setup.</param>
/// <returns>Response on updating locking state.</returns>
Task<ReservationBookingResponse> UpdateLockingStateAsync(
string bikeId,
lock_state state,
Uri operatorUri,
LocationDto location = null,
2022-09-20 13:51:55 +02:00
double batteryPercentage = double.NaN,
IVersionInfo versionInfo = null);
2022-09-06 16:08:19 +02:00
/// <summary> Books a bluetooth bike. </summary>
2022-12-27 21:08:09 +01:00
/// <param name="operatorUri">Holds the uri of the operator or null, in case of single operator setup.</param>
2022-09-06 16:08:19 +02:00
/// <param name="bikeId">Id of the bike to book.</param>
/// <param name="guid">Used to publish GUID from app to copri. Used for initial setup of bike in copri.</param>
/// <param name="batteryPercentage">Holds the filling level percentage of the battery.</param>
2022-12-27 21:08:09 +01:00
/// <param name="nextAction">If not null next locking action which is performed after booking.</param>
2022-09-06 16:08:19 +02:00
/// <returns>Response on booking request.</returns>
Task<ReservationBookingResponse> DoBookAsync(
2022-12-27 21:08:09 +01:00
Uri operatorUri,
2022-09-06 16:08:19 +02:00
string bikeId,
Guid guid,
2022-12-27 21:08:09 +01:00
double batteryPercentage,
LockingAction? nextAction = null);
2022-09-06 16:08:19 +02:00
/// <summary> Books a bike and starts opening bike. </summary>
/// <param name="bikeId">Id of the bike to book.</param>
/// <param name="operatorUri">Holds the uri of the operator or null, in case of single operator setup.</param>
/// <returns>Response on booking request.</returns>
Task<ReservationBookingResponse> BookAvailableAndStartOpeningAsync(
string bikeId,
Uri operatorUri);
/// <summary> Books a bike and starts opening bike. </summary>
/// <param name="bikeId">Id of the bike to book.</param>
/// <param name="operatorUri">Holds the uri of the operator or null, in case of single operator setup.</param>
/// <returns>Response on booking request.</returns>
Task<ReservationBookingResponse> BookReservedAndStartOpeningAsync(
string bikeId,
Uri operatorUri);
/// <summary> Returns a bike. </summary>
/// <param name="bikeId">Id of the bike to return.</param>
/// <param name="location">Geolocation of lock.</param>
/// <param name="operatorUri">Holds the uri of the operator or null, in case of single operator setup.</param>
/// <returns>Response on returning request.</returns>
Task<DoReturnResponse> DoReturn(
string bikeId,
LocationDto location,
Uri operatorUri);
/// <summary> Returns a bike and starts closing. </summary>
/// <param name="bikeId">Id of the bike to return.</param>
/// <param name="smartDevice">Provides info about hard and software.</param>
/// <param name="operatorUri">Holds the uri of the operator or null, in case of single operator setup.</param>
/// <returns>Response on returning request.</returns>
Task<DoReturnResponse> ReturnAndStartClosingAsync(
string bikeId,
Uri operatorUri);
/// <summary>
/// Submits feedback to copri server.
/// </summary>
/// <param name="bikeId">Id of the bike to submit feedback for.</param>
/// <param name="currentChargeBars">Null if bike has no engine or charge is unknown. Otherwise the charge filling level of the drive battery.</param>
/// <param name="isBikeBroken">True if bike is broken.</param>
/// <param name="message">General purpose message or error description.</param>
Task<SubmitFeedbackResponse> DoSubmitFeedback(
string bikeId,
int? currentChargeBars,
string message,
bool isBikeBroken,
Uri operatorUri);
/// <summary> Submits mini survey to copri server. </summary>
/// <param name="answers">Collection of answers.</param>
Task<ResponseBase> DoSubmitMiniSurvey(IDictionary<string, string> answers);
/// <summary> True if connector has access to copri server, false if cached values are used. </summary>
bool IsConnected { get; }
/// <summary> Gets the session cookie if user is logged in, an empty string otherwise. </summary>
string SessionCookie { get; }
/// <summary> Holds the id of the merchant. </summary>
string MerchantId { get; }
}
/// <summary> Interface to communicate with copri server.</summary>
public interface ICopriServer : ICopriServerBase
{
/// <summary> Get list of stations. </summary>
/// <returns>List of all stations.</returns>
Task<StationsAvailableResponse> GetStationsAsync();
/// <summary> Gets a list of bikes from Copri. </summary>
/// <returns>Response holding list of bikes.</returns>
Task<BikesAvailableResponse> GetBikesAvailableAsync();
/// <summary> Gets a list of bikes reserved/ booked by acctive user from Copri.</summary>
/// <returns>Response holding list of bikes.</returns>
Task<BikesReservedOccupiedResponse> GetBikesOccupiedAsync();
}
2021-05-13 20:03:07 +02:00
}