mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2024-11-15 14:46:39 +01:00
177 lines
7.1 KiB
C#
177 lines
7.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using TINK.Model.Bikes.BikeInfoNS.BluetoothLock;
|
|
using TINK.Model.Connector;
|
|
|
|
namespace TINK.Repository.Request
|
|
{
|
|
/// <summary> Defines members to create requests.</summary>
|
|
public interface IRequestBuilder
|
|
{
|
|
/// <summary> Holds the id denoting the merchant (TINK app). </summary>
|
|
string MerchantId { get; }
|
|
|
|
/// <summary> Gets the session cookie if user is logged in, an empty string otherwise. </summary>
|
|
string SessionCookie { get; }
|
|
|
|
/// <summary> Gets request to log user in. </summary>
|
|
/// <param name="mailAddress">Mail address of user to log in.</param>
|
|
/// <param name="password">Password to log in.</param>
|
|
/// <param name="deviceId">Id specifying user and hardware.</param>
|
|
/// <remarks>Request which holds auth cookie <see cref="RequstBase.authcookie"/></remarks>
|
|
string DoAuthorization(
|
|
string mailAddress,
|
|
string password,
|
|
string deviceId);
|
|
|
|
/// <summary> Logs user out. </summary>
|
|
/// <param name="merchantId">Id of the merchant.</param>
|
|
/// <param name="p_strSessionCookie"> Cookie which identifies user.</param>
|
|
string DoAuthout();
|
|
|
|
/// <summary> Get list of stations from file. </summary>
|
|
/// <returns>Request to query list of station.</returns>
|
|
string GetStations();
|
|
|
|
/// <summary>Gets bikes available.</summary>
|
|
/// <param name="stationId"> Id of station which is used for filtering bikes. Null if no filtering should be applied.</param>
|
|
/// <param name="bikeId"> Id of bike to get.</param>
|
|
/// <returns>Request to query list of bikes available.</returns>
|
|
string GetBikesAvailable(string stationId = null, string bikeId = null);
|
|
|
|
/// <summary> Gets a list of bikes reserved/ booked by active user from Copri.</summary>
|
|
/// <returns>Request to query list of bikes occupied.</returns>
|
|
string GetBikesOccupied();
|
|
|
|
/// <summary> Gets reservation request (synonym: reservation == request == reservieren). </summary>
|
|
/// <param name="bikeId">Id of the bike to reserve.</param>
|
|
/// <returns>Request to reserve bike.</returns>
|
|
string DoReserve(string bikeId);
|
|
|
|
/// <summary> Gets request to cancel reservation. </summary>
|
|
/// <param name="bikeId">Id of the bike to cancel reservation for.</param>
|
|
/// <returns>Request on cancel booking request.</returns>
|
|
string DoCancelReservation(string bikeId);
|
|
|
|
/// <summary> Request to get keys. </summary>
|
|
/// <param name="bikeId">Id of the bike to get keys for.</param>
|
|
/// <returns>Request to get keys.</returns>
|
|
string CalculateAuthParameters(string bikeId);
|
|
|
|
/// <summary> Gets the request for notifying about start of returning sequence. </summary>
|
|
/// <remarks> Operator specific call.</remarks>
|
|
/// <param name="bikeId">Id of the bike to return.</param>
|
|
/// <returns>Request to notify about start of returning sequence.</returns>
|
|
string StartReturningBike(string bikeId);
|
|
|
|
/// <summary> Gets the request for updating lock state for a booked bike. </summary>
|
|
/// <param name="bikeId">Id of the bike to update locking state for.</param>
|
|
/// <param name="state">New locking state.</param>
|
|
/// <param name="location">Geolocation of lock when state change occurred.</param>
|
|
/// <param name="versionInfo">Information about lock (firmware version, hardware version, ...).</param>
|
|
/// <returns>Request to update locking state.</returns>
|
|
string UpdateLockingState(
|
|
string bikeId,
|
|
lock_state state,
|
|
LocationDto location = null,
|
|
double batteryPercentage = double.NaN,
|
|
IVersionInfo versionInfo = null);
|
|
|
|
/// <summary> Gets the booking request (synonym: booking == renting == mieten). </summary>
|
|
/// <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>
|
|
/// <param name="nextAction">If not null next locking action which is performed after booking.</param>
|
|
/// <returns>Request to booking bike.</returns>
|
|
string DoBook(string bikeId, Guid guid, double batteryPercentage, LockingAction? nextAction = null);
|
|
|
|
/// <summary> Gets the request to book and start opening the bike (synonym: booking == renting == mieten). </summary>
|
|
/// <param name="bikeId">Id of the bike to book.</param>
|
|
/// <returns>Request to booking bike.</returns>
|
|
string BookAvailableAndStartOpening(string bikeId);
|
|
|
|
/// <summary> Gets the request to book and start opening the bike (synonym: booking == renting == mieten). </summary>
|
|
/// <param name="bikeId">Id of the bike to book.</param>
|
|
/// <returns>Request to booking bike.</returns>
|
|
string BookReservedAndStartOpening(string bikeId);
|
|
|
|
/// <summary> Gets request for returning the bike. </summary>
|
|
/// <param name="bikeId">Id of the bike to return.</param>
|
|
/// <param name="location">Geolocation of lock when returning bike.</param>
|
|
/// <returns>Request on returning request.</returns>
|
|
string DoReturn(string bikeId, LocationDto location);
|
|
|
|
/// <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>
|
|
/// <returns>Response to send to copri.</returns>
|
|
string ReturnAndStartClosing(string bikeId);
|
|
|
|
/// <summary>
|
|
/// Gets request for submitting feedback to copri server.
|
|
/// </summary>
|
|
/// <param name="bikeId">Id of the bike to which the feedback is related to.</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="message">General purpose message or error description.</param>
|
|
/// <param name="isBikeBroken">True if bike is broken.</param>
|
|
string DoSubmitFeedback(
|
|
string bikeId,
|
|
int? currentChargeBars,
|
|
string message = null,
|
|
bool isBikeBroken = false);
|
|
|
|
/// <summary>
|
|
/// Gets request for submitting mini survey to copri server.
|
|
/// </summary>
|
|
/// <param name="answers">Collection of answers.</param>
|
|
string DoSubmitMiniSurvey(IDictionary<string, string> answers);
|
|
}
|
|
|
|
/// <summary> Copri locking states</summary>
|
|
public enum lock_state
|
|
{
|
|
/// <summary> Request to backend to close lock in context of pausing ride.</summary>
|
|
locking,
|
|
|
|
/// <summary> Lock is closed.</summary>
|
|
locked,
|
|
|
|
/// <summary> Request to backend to close lock either in context of resuming ride or starting a rental.</summary>
|
|
unlocking,
|
|
|
|
/// <summary> Lock is open.</summary>
|
|
unlocked,
|
|
|
|
/// <summary> Lock is unknown state.</summary>
|
|
unspecific,
|
|
}
|
|
|
|
/// <summary> Holds location info.</summary>
|
|
public class LocationDto
|
|
{
|
|
public double Latitude { get; private set; }
|
|
|
|
public double Longitude { get; private set; }
|
|
|
|
/// <summary> Accuracy of location in meters.</summary>
|
|
public double? Accuracy { get; private set; }
|
|
|
|
public TimeSpan Age { get; private set; }
|
|
|
|
public class Builder
|
|
{
|
|
public double Latitude { get; set; }
|
|
|
|
public double Longitude { get; set; }
|
|
|
|
public double? Accuracy { get; set; }
|
|
|
|
public TimeSpan Age { get; set; }
|
|
|
|
public LocationDto Build()
|
|
{
|
|
return new LocationDto { Latitude = Latitude, Longitude = Longitude, Accuracy = Accuracy, Age = Age };
|
|
}
|
|
}
|
|
}
|
|
}
|