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

133 lines
5.5 KiB
C#
Raw Normal View History

2021-05-13 20:03:07 +02:00
using System;
2021-08-01 17:24:15 +02:00
using System.Collections.Generic;
2021-06-26 20:57:55 +02:00
using TINK.Model.Device;
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
{
/// <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">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>Requst which holds auth cookie <see cref="RequstBase.authcookie"/></remarks>
string DoAuthorization(
string mailAddress,
string password,
string deviceId);
/// <summary> Logs user out. </summary>
/// <param name="p_strMerchantId">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>
/// <returns>Request to query list of bikes available.</returns>
string GetBikesAvailable();
/// <summary> Gets a list of bikes reserved/ booked by acctive 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>Requst to reserve bike.</returns>
2021-06-26 20:57:55 +02:00
string DoReserve(string bikeId);
2021-05-13 20:03:07 +02:00
/// <summary> Gets request to cancel reservation. </summary>
/// <param name="bikeId">Id of the bike to cancel reservation for.</param>
/// <returns>Requst on cancel booking request.</returns>
2021-06-26 20:57:55 +02:00
string DoCancelReservation(string bikeId);
2021-05-13 20:03:07 +02:00
/// <summary> Request to get keys. </summary>
/// <param name="bikeId">Id of the bike to get keys for.</param>
/// <returns>Request to get keys.</returns>
2021-06-26 20:57:55 +02:00
string CalculateAuthParameters(string bikeId);
2021-05-13 20:03:07 +02:00
/// <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="location">Geolocation of lock when state change occurred.</param>
/// <param name="state">New locking state.</param>
/// <returns>Request to update locking state.</returns>
string UpateLockingState(
2021-06-26 20:57:55 +02:00
string bikeId,
2021-05-13 20:03:07 +02:00
LocationDto location,
lock_state state,
double batteryPercentage);
/// <summary> Gets booking request 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>
/// <returns>Request to booking bike.</returns>
2021-06-26 20:57:55 +02:00
string DoBook(string bikeId, Guid guid, double batteryPercentage);
2021-05-13 20:03:07 +02:00
/// <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>Requst on returning request.</returns>
2021-06-26 20:57:55 +02:00
string DoReturn(string bikeId, LocationDto location, ISmartDevice smartDevice);
2021-05-13 20:03:07 +02:00
/// <summary>
/// Gets request for submiting feedback to copri server.
/// </summary>
2021-06-26 20:57:55 +02:00
/// <param name="bikeId">Id of the bike to which the feedback is related to.</param>
2021-05-13 20:03:07 +02:00
/// <param name="message">General purpose message or error description.</param>
/// <param name="isBikeBroken">True if bike is broken.</param>
2021-06-26 20:57:55 +02:00
string DoSubmitFeedback(string bikeId, string message = null, bool isBikeBroken = false);
2021-08-01 17:24:15 +02:00
/// <summary>
/// Gets request for submiting mini survey to copri server.
/// </summary>
/// <param name="answers">Collection of answers.</param>
string DoSubmitMiniSurvey(IDictionary<string, string> answers);
2021-05-13 20:03:07 +02:00
}
/// <summary> Copri locking states</summary>
public enum lock_state
{
locked,
unlocked
}
2021-06-26 20:57:55 +02:00
/// <summary> Holds lockation info.</summary>
2021-05-13 20:03:07 +02:00
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 };
}
}
}
}