sharee.bike-App/TINKLib/Repository/Request/IRequestBuilder.cs

166 lines
6.6 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;
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-05-13 20:03:07 +02:00
2021-06-26 20:57:55 +02:00
namespace TINK.Repository.Request
2021-05-13 20:03:07 +02:00
{
2022-09-06 16:08:19 +02:00
/// <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>
2023-04-19 12:14:14 +02:00
/// <param name="mailAddress">Mail address of user to log in.</param>
2022-09-06 16:08:19 +02:00
/// <param name="password">Password to log in.</param>
/// <param name="deviceId">Id specifying user and hardware.</param>
2023-04-19 12:14:14 +02:00
/// <remarks>Request which holds auth cookie <see cref="RequstBase.authcookie"/></remarks>
2022-09-06 16:08:19 +02:00
string DoAuthorization(
string mailAddress,
string password,
string deviceId);
/// <summary> Logs user out. </summary>
2023-02-22 14:03:35 +01:00
/// <param name="merchantId">Id of the merchant.</param>
2022-09-06 16:08:19 +02:00
/// <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>
/// <returns>Request to query list of bikes available.</returns>
string GetBikesAvailable();
2023-04-19 12:14:14 +02:00
/// <summary> Gets a list of bikes reserved/ booked by active user from Copri.</summary>
2022-09-06 16:08:19 +02:00
/// <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>
2023-05-09 08:47:52 +02:00
/// <returns>Request to reserve bike.</returns>
2022-09-06 16:08:19 +02:00
string DoReserve(string bikeId);
/// <summary> Gets request to cancel reservation. </summary>
/// <param name="bikeId">Id of the bike to cancel reservation for.</param>
2023-05-09 08:47:52 +02:00
/// <returns>Request on cancel booking request.</returns>
2022-09-06 16:08:19 +02:00
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>
2022-09-20 13:51:55 +02:00
/// <param name="location">Geolocation of lock when state change occurred.</param>
/// <param name="versionInfo">Information about lock (firmware version, hardware version, ...).</param>
2022-09-06 16:08:19 +02:00
/// <returns>Request to update locking state.</returns>
2023-07-04 11:06:38 +02:00
string UpdateLockingState(
2022-09-06 16:08:19 +02:00
string bikeId,
lock_state state,
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> 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>
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>Request to booking bike.</returns>
2022-12-27 21:08:09 +01:00
string DoBook(string bikeId, Guid guid, double batteryPercentage, LockingAction? nextAction = null);
2022-09-06 16:08:19 +02:00
/// <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>
2023-05-09 08:47:52 +02:00
/// <returns>Request on returning request.</returns>
2023-02-22 14:03:35 +01:00
string DoReturn(string bikeId, LocationDto location);
2022-09-06 16:08:19 +02:00
/// <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>
2023-05-09 08:47:52 +02:00
/// <returns>Response to send to copri.</returns>
2023-02-22 14:03:35 +01:00
string ReturnAndStartClosing(string bikeId);
2022-09-06 16:08:19 +02:00
/// <summary>
2023-05-09 08:47:52 +02:00
/// Gets request for submitting feedback to copri server.
2022-09-06 16:08:19 +02:00
/// </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>
2023-05-09 08:47:52 +02:00
/// Gets request for submitting mini survey to copri server.
2022-09-06 16:08:19 +02:00
/// </summary>
/// <param name="answers">Collection of answers.</param>
string DoSubmitMiniSurvey(IDictionary<string, string> answers);
}
/// <summary> Copri locking states</summary>
public enum lock_state
{
locking,
locked,
unlocking,
unlocked,
}
/// <summary> Holds lockation 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 };
}
}
}
2021-05-13 20:03:07 +02:00
}