mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-06-22 05:47:28 +02:00
Version 3.0.338
This commit is contained in:
parent
573fe77e12
commit
0468955d49
751 changed files with 62747 additions and 60672 deletions
|
@ -4,158 +4,158 @@ using TINK.Model.Device;
|
|||
|
||||
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> 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 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> 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> 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> 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 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 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>
|
||||
string DoReserve(string bikeId);
|
||||
/// <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>
|
||||
string DoReserve(string bikeId);
|
||||
|
||||
/// <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>
|
||||
string DoCancelReservation(string bikeId);
|
||||
/// <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>
|
||||
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> 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 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="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(
|
||||
string bikeId,
|
||||
lock_state state,
|
||||
LocationDto location = null,
|
||||
double batteryPercentage = double.NaN);
|
||||
/// <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(
|
||||
string bikeId,
|
||||
lock_state state,
|
||||
LocationDto location = null,
|
||||
double batteryPercentage = double.NaN);
|
||||
|
||||
/// <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>
|
||||
/// <returns>Request to booking bike.</returns>
|
||||
string DoBook(string bikeId, Guid guid, double batteryPercentage);
|
||||
/// <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>
|
||||
/// <returns>Request to booking bike.</returns>
|
||||
string DoBook(string bikeId, Guid guid, double batteryPercentage);
|
||||
|
||||
/// <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 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 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>Requst on returning request.</returns>
|
||||
string DoReturn(string bikeId, LocationDto location, ISmartDevice smartDevice);
|
||||
/// <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>
|
||||
string DoReturn(string bikeId, LocationDto location, ISmartDevice smartDevice);
|
||||
|
||||
/// <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 corpi.</returns>
|
||||
string ReturnAndStartClosing(string bikeId, ISmartDevice smartDevice);
|
||||
/// <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 corpi.</returns>
|
||||
string ReturnAndStartClosing(string bikeId, ISmartDevice smartDevice);
|
||||
|
||||
/// <summary>
|
||||
/// Gets request for submiting 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 submiting 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 submiting mini survey to copri server.
|
||||
/// </summary>
|
||||
/// <param name="answers">Collection of answers.</param>
|
||||
string DoSubmitMiniSurvey(IDictionary<string, string> answers);
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets request for submiting 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
|
||||
{
|
||||
locking,
|
||||
locked,
|
||||
unlocking,
|
||||
unlocked,
|
||||
}
|
||||
/// <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; }
|
||||
/// <summary> Holds lockation info.</summary>
|
||||
public class LocationDto
|
||||
{
|
||||
public double Latitude { get; private set; }
|
||||
|
||||
public double Longitude { get; private set; }
|
||||
public double Longitude { get; private set; }
|
||||
|
||||
/// <summary> Accuracy of location in meters.</summary>
|
||||
public double? Accuracy { get; private set; }
|
||||
/// <summary> Accuracy of location in meters.</summary>
|
||||
public double? Accuracy { get; private set; }
|
||||
|
||||
public TimeSpan Age { get; private set; }
|
||||
public TimeSpan Age { get; private set; }
|
||||
|
||||
public class Builder
|
||||
{
|
||||
public double Latitude { get; set; }
|
||||
public class Builder
|
||||
{
|
||||
public double Latitude { get; set; }
|
||||
|
||||
public double Longitude { get; set; }
|
||||
public double Longitude { get; set; }
|
||||
|
||||
public double? Accuracy { get; set; }
|
||||
public double? Accuracy { get; set; }
|
||||
|
||||
public TimeSpan Age { get; set; }
|
||||
public TimeSpan Age { get; set; }
|
||||
|
||||
public LocationDto Build()
|
||||
{
|
||||
return new LocationDto { Latitude = Latitude, Longitude = Longitude, Accuracy = Accuracy, Age = Age };
|
||||
}
|
||||
}
|
||||
}
|
||||
public LocationDto Build()
|
||||
{
|
||||
return new LocationDto { Latitude = Latitude, Longitude = Longitude, Accuracy = Accuracy, Age = Age };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,28 +1,28 @@
|
|||
|
||||
namespace TINK.Repository.Request
|
||||
{
|
||||
public static class QueryBuilderHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the htlm query string element for session id.
|
||||
/// </summary>
|
||||
/// <returns>Query string.</returns>
|
||||
public static string GetSessionIdQueryElement(
|
||||
string op,
|
||||
string merchantId,
|
||||
string sessionCookie = null)
|
||||
=> !string.IsNullOrEmpty(merchantId) || !string.IsNullOrEmpty(sessionCookie)
|
||||
? $"{op}sessionid={(!string.IsNullOrEmpty(sessionCookie) ? sessionCookie : string.Empty)}{(!string.IsNullOrEmpty(merchantId) ? merchantId : string.Empty)}"
|
||||
: string.Empty;
|
||||
public static class QueryBuilderHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the htlm query string element for session id.
|
||||
/// </summary>
|
||||
/// <returns>Query string.</returns>
|
||||
public static string GetSessionIdQueryElement(
|
||||
string op,
|
||||
string merchantId,
|
||||
string sessionCookie = null)
|
||||
=> !string.IsNullOrEmpty(merchantId) || !string.IsNullOrEmpty(sessionCookie)
|
||||
? $"{op}sessionid={(!string.IsNullOrEmpty(sessionCookie) ? sessionCookie : string.Empty)}{(!string.IsNullOrEmpty(merchantId) ? merchantId : string.Empty)}"
|
||||
: string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the htlm query string element for the language.
|
||||
/// </summary>
|
||||
/// <param name="uiIsoLangugageName">Two letter ISO language name.</param>
|
||||
/// <returns>Query string.</returns>
|
||||
public static string GetLanguageQueryElement(string op, string uiIsoLangugageName)
|
||||
=> !string.IsNullOrEmpty(uiIsoLangugageName)
|
||||
? $"{op}lang={uiIsoLangugageName}"
|
||||
: string.Empty;
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the htlm query string element for the language.
|
||||
/// </summary>
|
||||
/// <param name="uiIsoLangugageName">Two letter ISO language name.</param>
|
||||
/// <returns>Query string.</returns>
|
||||
public static string GetLanguageQueryElement(string op, string uiIsoLangugageName)
|
||||
=> !string.IsNullOrEmpty(uiIsoLangugageName)
|
||||
? $"{op}lang={uiIsoLangugageName}"
|
||||
: string.Empty;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,142 +6,142 @@ using TINK.Repository.Exception;
|
|||
|
||||
namespace TINK.Repository.Request
|
||||
{
|
||||
/// <summary> Creates requests if no user is logged in.</summary>
|
||||
public class RequestBuilder : IRequestBuilder
|
||||
{
|
||||
/// <summary> Constructs a object for building requests. </summary>
|
||||
/// <param name="merchantId"></param>
|
||||
/// <param name="uiIsoLangugageName">Two letter ISO language name.</param>
|
||||
public RequestBuilder(
|
||||
string merchantId,
|
||||
string uiIsoLangugageName)
|
||||
{
|
||||
MerchantId = !string.IsNullOrEmpty(merchantId)
|
||||
? merchantId
|
||||
: throw new ArgumentException("Merchant id must not be null.", nameof(merchantId));
|
||||
/// <summary> Creates requests if no user is logged in.</summary>
|
||||
public class RequestBuilder : IRequestBuilder
|
||||
{
|
||||
/// <summary> Constructs a object for building requests. </summary>
|
||||
/// <param name="merchantId"></param>
|
||||
/// <param name="uiIsoLangugageName">Two letter ISO language name.</param>
|
||||
public RequestBuilder(
|
||||
string merchantId,
|
||||
string uiIsoLangugageName)
|
||||
{
|
||||
MerchantId = !string.IsNullOrEmpty(merchantId)
|
||||
? merchantId
|
||||
: throw new ArgumentException("Merchant id must not be null.", nameof(merchantId));
|
||||
|
||||
UiIsoLanguageNameParameter = RequestBuilderHelper.GetLanguageParameter(uiIsoLangugageName);
|
||||
UiIsoLanguageNameParameter = RequestBuilderHelper.GetLanguageParameter(uiIsoLangugageName);
|
||||
|
||||
AuthCookieParameter = $"&authcookie={MerchantId}";
|
||||
}
|
||||
AuthCookieParameter = $"&authcookie={MerchantId}";
|
||||
}
|
||||
|
||||
/// <summary> Parameter specifying current ui language. </summary>
|
||||
public string MerchantId { get; }
|
||||
/// <summary> Parameter specifying current ui language. </summary>
|
||||
public string MerchantId { get; }
|
||||
|
||||
/// <summary> Holds the session cookie if a user is logged in. </summary>
|
||||
public string SessionCookie => string.Empty;
|
||||
/// <summary> Holds the session cookie if a user is logged in. </summary>
|
||||
public string SessionCookie => string.Empty;
|
||||
|
||||
/// <summary> Holds the current ui two letter ISO language name. </summary>
|
||||
private string UiIsoLanguageNameParameter { get; }
|
||||
/// <summary> Holds the current ui two letter ISO language name. </summary>
|
||||
private string UiIsoLanguageNameParameter { get; }
|
||||
|
||||
/// <summary> Auth cookie parameter. </summary>
|
||||
private string AuthCookieParameter { get; }
|
||||
/// <summary> Auth cookie parameter. </summary>
|
||||
private string AuthCookieParameter { 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>Response which holds auth cookie <see cref="ResponseBase.authcookie"/></remarks>
|
||||
public string DoAuthorization(
|
||||
string mailAddress,
|
||||
string password,
|
||||
string deviceId)
|
||||
=> "request=authorization" +
|
||||
$"&merchant_id={MerchantId}" +
|
||||
$"&user_id={WebUtility.UrlEncode(mailAddress)}" +
|
||||
$"&user_pw={WebUtility.UrlEncode(password)}" +
|
||||
$"&hw_id={deviceId}" +
|
||||
UiIsoLanguageNameParameter;
|
||||
/// <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>Response which holds auth cookie <see cref="ResponseBase.authcookie"/></remarks>
|
||||
public string DoAuthorization(
|
||||
string mailAddress,
|
||||
string password,
|
||||
string deviceId)
|
||||
=> "request=authorization" +
|
||||
$"&merchant_id={MerchantId}" +
|
||||
$"&user_id={WebUtility.UrlEncode(mailAddress)}" +
|
||||
$"&user_pw={WebUtility.UrlEncode(password)}" +
|
||||
$"&hw_id={deviceId}" +
|
||||
UiIsoLanguageNameParameter;
|
||||
|
||||
/// <summary> Logs user out. </summary>
|
||||
public string DoAuthout()
|
||||
=> throw new CallNotRequiredException();
|
||||
/// <summary> Logs user out. </summary>
|
||||
public string DoAuthout()
|
||||
=> throw new CallNotRequiredException();
|
||||
|
||||
/// <summary>Gets bikes available.</summary>
|
||||
/// <returns>Request to query list of bikes available.</returns>
|
||||
public string GetBikesAvailable()
|
||||
=> "request=bikes_available&system=all" +
|
||||
AuthCookieParameter +
|
||||
UiIsoLanguageNameParameter;
|
||||
/// <summary>Gets bikes available.</summary>
|
||||
/// <returns>Request to query list of bikes available.</returns>
|
||||
public string GetBikesAvailable()
|
||||
=> "request=bikes_available&system=all" +
|
||||
AuthCookieParameter +
|
||||
UiIsoLanguageNameParameter;
|
||||
|
||||
/// <summary> Get list of stations from file. </summary>
|
||||
/// <returns>Request to query list of station.</returns>
|
||||
public string GetStations()
|
||||
=> "request=stations_available" +
|
||||
AuthCookieParameter +
|
||||
UiIsoLanguageNameParameter;
|
||||
/// <summary> Get list of stations from file. </summary>
|
||||
/// <returns>Request to query list of station.</returns>
|
||||
public string GetStations()
|
||||
=> "request=stations_available" +
|
||||
AuthCookieParameter +
|
||||
UiIsoLanguageNameParameter;
|
||||
|
||||
/// <summary> Gets a list of bikes reserved/ booked by acctive user from Copri.</summary>
|
||||
/// <returns>Request to query list of bikes occupied.</returns>
|
||||
public string GetBikesOccupied()
|
||||
=> throw new NotSupportedException();
|
||||
/// <summary> Gets a list of bikes reserved/ booked by acctive user from Copri.</summary>
|
||||
/// <returns>Request to query list of bikes occupied.</returns>
|
||||
public string GetBikesOccupied()
|
||||
=> throw new NotSupportedException();
|
||||
|
||||
/// <summary> Gets booking request response. </summary>
|
||||
/// <param name="bikeId">Id of the bike to book.</param>
|
||||
/// <returns>Response on booking request.</returns>
|
||||
public string DoReserve(string bikeId)
|
||||
=> throw new NotSupportedException();
|
||||
/// <summary> Gets booking request response. </summary>
|
||||
/// <param name="bikeId">Id of the bike to book.</param>
|
||||
/// <returns>Response on booking request.</returns>
|
||||
public string DoReserve(string bikeId)
|
||||
=> throw new NotSupportedException();
|
||||
|
||||
/// <summary> Gets cancel booking request response. </summary>
|
||||
/// <param name="p_iBikeId">Id of the bike to book.</param>
|
||||
/// <returns>Response on cancel booking request.</returns>
|
||||
public string DoCancelReservation(string p_iBikeId)
|
||||
=> throw new NotSupportedException();
|
||||
/// <summary> Gets cancel booking request response. </summary>
|
||||
/// <param name="p_iBikeId">Id of the bike to book.</param>
|
||||
/// <returns>Response on cancel booking request.</returns>
|
||||
public string DoCancelReservation(string p_iBikeId)
|
||||
=> throw new NotSupportedException();
|
||||
|
||||
/// <summary> Request to calculate authentication keys. </summary>
|
||||
/// <param name="bikeId">Id of the bike to get keys for.</param>
|
||||
/// <returns>Response on request.</returns>
|
||||
public string CalculateAuthParameters(string bikeId)
|
||||
=> throw new NotSupportedException();
|
||||
/// <summary> Request to calculate authentication keys. </summary>
|
||||
/// <param name="bikeId">Id of the bike to get keys for.</param>
|
||||
/// <returns>Response on request.</returns>
|
||||
public string CalculateAuthParameters(string bikeId)
|
||||
=> throw new NotSupportedException();
|
||||
|
||||
/// <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>
|
||||
public string StartReturningBike(string bikeId)
|
||||
=> throw new NotSupportedException();
|
||||
/// <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>
|
||||
public string StartReturningBike(string bikeId)
|
||||
=> throw new NotSupportedException();
|
||||
|
||||
public string UpateLockingState(string bikeId, lock_state state, LocationDto geolocation, double batteryPercentage)
|
||||
=> throw new NotSupportedException();
|
||||
public string UpateLockingState(string bikeId, lock_state state, LocationDto geolocation, double batteryPercentage)
|
||||
=> throw new NotSupportedException();
|
||||
|
||||
public string DoBook(string bikeId, Guid guid, double batteryPercentage)
|
||||
=> throw new NotSupportedException();
|
||||
public string DoBook(string bikeId, Guid guid, double batteryPercentage)
|
||||
=> throw new NotSupportedException();
|
||||
|
||||
/// <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>
|
||||
public string BookAvailableAndStartOpening(string bikeId)
|
||||
=> throw new NotSupportedException();
|
||||
/// <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>
|
||||
public string BookAvailableAndStartOpening(string bikeId)
|
||||
=> throw new NotSupportedException();
|
||||
|
||||
/// <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>
|
||||
public string BookReservedAndStartOpening(string bikeId)
|
||||
=> throw new NotSupportedException();
|
||||
/// <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>
|
||||
public string BookReservedAndStartOpening(string bikeId)
|
||||
=> throw new NotSupportedException();
|
||||
|
||||
public string DoReturn(string bikeId, LocationDto geolocation, ISmartDevice smartDevice)
|
||||
=> throw new NotSupportedException();
|
||||
public string DoReturn(string bikeId, LocationDto geolocation, ISmartDevice smartDevice)
|
||||
=> throw new NotSupportedException();
|
||||
|
||||
/// <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 corpi.</returns>
|
||||
public string ReturnAndStartClosing(string bikeId, ISmartDevice smartDevice)
|
||||
=> throw new NotSupportedException();
|
||||
/// <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 corpi.</returns>
|
||||
public string ReturnAndStartClosing(string bikeId, ISmartDevice smartDevice)
|
||||
=> throw new NotSupportedException();
|
||||
|
||||
/// <summary> Gets submit feedback request. </summary>
|
||||
/// <param name="bikeId">Id of the bike to which the feedback is related to.</param>
|
||||
/// <param name="message">General purpose message or error description.</param>
|
||||
/// <param name="isBikeBroken">True if bike is broken.</param>
|
||||
/// <returns>Submit feedback request.</returns>
|
||||
public string DoSubmitFeedback(string bikeId, int? currentChargeBars, string message = null, bool isBikeBroken = false)
|
||||
=> throw new NotSupportedException();
|
||||
/// <summary> Gets submit feedback request. </summary>
|
||||
/// <param name="bikeId">Id of the bike to which the feedback is related to.</param>
|
||||
/// <param name="message">General purpose message or error description.</param>
|
||||
/// <param name="isBikeBroken">True if bike is broken.</param>
|
||||
/// <returns>Submit feedback request.</returns>
|
||||
public string DoSubmitFeedback(string bikeId, int? currentChargeBars, string message = null, bool isBikeBroken = false)
|
||||
=> throw new NotSupportedException();
|
||||
|
||||
/// <summary>
|
||||
/// Gets request for submiting mini survey to copri server.
|
||||
/// </summary>
|
||||
/// <param name="answers">Collection of answers.</param>
|
||||
public string DoSubmitMiniSurvey(IDictionary<string, string> answers) =>
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets request for submiting mini survey to copri server.
|
||||
/// </summary>
|
||||
/// <param name="answers">Collection of answers.</param>
|
||||
public string DoSubmitMiniSurvey(IDictionary<string, string> answers) =>
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
|
||||
namespace TINK.Repository.Request
|
||||
{
|
||||
public static class RequestBuilderHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the REST language parameter.
|
||||
/// </summary>
|
||||
/// <param name="uiIsoLangugageName">Two letter ISO language name.</param>
|
||||
/// <returns></returns>
|
||||
public static string GetLanguageParameter(string uiIsoLangugageName)
|
||||
=> !string.IsNullOrEmpty(uiIsoLangugageName)
|
||||
? $"&lang={uiIsoLangugageName}"
|
||||
: string.Empty;
|
||||
}
|
||||
public static class RequestBuilderHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the REST language parameter.
|
||||
/// </summary>
|
||||
/// <param name="uiIsoLangugageName">Two letter ISO language name.</param>
|
||||
/// <returns></returns>
|
||||
public static string GetLanguageParameter(string uiIsoLangugageName)
|
||||
=> !string.IsNullOrEmpty(uiIsoLangugageName)
|
||||
? $"&lang={uiIsoLangugageName}"
|
||||
: string.Empty;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,303 +9,303 @@ using TINK.Services.Logging;
|
|||
|
||||
namespace TINK.Repository.Request
|
||||
{
|
||||
/// <summary> Creates requests if a user is logged in.</summary>
|
||||
public class RequestBuilderLoggedIn : IRequestBuilder
|
||||
{
|
||||
/// <summary> Constructs a object for building requests. </summary>
|
||||
/// <param name="merchantId"></param>
|
||||
/// <param name="uiIsoLangugageName">Two letter ISO language name.</param>
|
||||
public RequestBuilderLoggedIn(
|
||||
string merchantId,
|
||||
string uiIsoLangugageName,
|
||||
string sessionCookie)
|
||||
{
|
||||
MerchantId = !string.IsNullOrEmpty(merchantId)
|
||||
? merchantId
|
||||
: throw new ArgumentException("Merchant id must not be null.", nameof(merchantId));
|
||||
/// <summary> Creates requests if a user is logged in.</summary>
|
||||
public class RequestBuilderLoggedIn : IRequestBuilder
|
||||
{
|
||||
/// <summary> Constructs a object for building requests. </summary>
|
||||
/// <param name="merchantId"></param>
|
||||
/// <param name="uiIsoLangugageName">Two letter ISO language name.</param>
|
||||
public RequestBuilderLoggedIn(
|
||||
string merchantId,
|
||||
string uiIsoLangugageName,
|
||||
string sessionCookie)
|
||||
{
|
||||
MerchantId = !string.IsNullOrEmpty(merchantId)
|
||||
? merchantId
|
||||
: throw new ArgumentException("Merchant id must not be null.", nameof(merchantId));
|
||||
|
||||
SessionCookie = !string.IsNullOrEmpty(sessionCookie)
|
||||
? sessionCookie
|
||||
: throw new ArgumentException("Session cookie must not be null.", nameof(sessionCookie));
|
||||
SessionCookie = !string.IsNullOrEmpty(sessionCookie)
|
||||
? sessionCookie
|
||||
: throw new ArgumentException("Session cookie must not be null.", nameof(sessionCookie));
|
||||
|
||||
UiIsoLanguageNameParameter = RequestBuilderHelper.GetLanguageParameter(uiIsoLangugageName);
|
||||
UiIsoLanguageNameParameter = RequestBuilderHelper.GetLanguageParameter(uiIsoLangugageName);
|
||||
|
||||
AuthCookieParameter = $"&authcookie={SessionCookie}{MerchantId}";
|
||||
}
|
||||
AuthCookieParameter = $"&authcookie={SessionCookie}{MerchantId}";
|
||||
}
|
||||
|
||||
/// <summary> Holds the id denoting the merchant (TINK app). </summary>
|
||||
public string MerchantId { get; }
|
||||
/// <summary> Holds the id denoting the merchant (TINK app). </summary>
|
||||
public string MerchantId { get; }
|
||||
|
||||
/// <summary> Holds the session cookie if a user is logged in. </summary>
|
||||
public string SessionCookie { get; }
|
||||
/// <summary> Holds the session cookie if a user is logged in. </summary>
|
||||
public string SessionCookie { get; }
|
||||
|
||||
/// <summary> Holds the current ui two letter ISO language name. </summary>
|
||||
public string UiIsoLanguageNameParameter { get; }
|
||||
/// <summary> Holds the current ui two letter ISO language name. </summary>
|
||||
public string UiIsoLanguageNameParameter { get; }
|
||||
|
||||
/// <summary> Auth cookie parameter. </summary>
|
||||
private string AuthCookieParameter { get; }
|
||||
/// <summary> Auth cookie parameter. </summary>
|
||||
private string AuthCookieParameter { 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>Response which holds auth cookie <see cref="ResponseBase.authcookie"/></remarks>
|
||||
public string DoAuthorization(
|
||||
string mailAddress,
|
||||
string password,
|
||||
string deviceId)
|
||||
=> throw new CallNotRequiredException();
|
||||
/// <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>Response which holds auth cookie <see cref="ResponseBase.authcookie"/></remarks>
|
||||
public string DoAuthorization(
|
||||
string mailAddress,
|
||||
string password,
|
||||
string deviceId)
|
||||
=> throw new CallNotRequiredException();
|
||||
|
||||
/// <summary> Logs user out. </summary>
|
||||
public string DoAuthout()
|
||||
=> "request=authout" +
|
||||
AuthCookieParameter +
|
||||
UiIsoLanguageNameParameter;
|
||||
/// <summary> Logs user out. </summary>
|
||||
public string DoAuthout()
|
||||
=> "request=authout" +
|
||||
AuthCookieParameter +
|
||||
UiIsoLanguageNameParameter;
|
||||
|
||||
/// <summary>Gets bikes available.</summary>
|
||||
/// <returns>Request to query list of bikes available.</returns>
|
||||
public string GetBikesAvailable()
|
||||
=> "request=bikes_available&system=all" +
|
||||
AuthCookieParameter +
|
||||
UiIsoLanguageNameParameter;
|
||||
/// <summary>Gets bikes available.</summary>
|
||||
/// <returns>Request to query list of bikes available.</returns>
|
||||
public string GetBikesAvailable()
|
||||
=> "request=bikes_available&system=all" +
|
||||
AuthCookieParameter +
|
||||
UiIsoLanguageNameParameter;
|
||||
|
||||
/// <summary> Gets a list of bikes reserved/ booked by acctive user from Copri.</summary>
|
||||
/// <returns>Request to query list of bikes occupied.</returns>
|
||||
public string GetBikesOccupied()
|
||||
=> "request=user_bikes_occupied&system=all&genkey=1" +
|
||||
AuthCookieParameter +
|
||||
UiIsoLanguageNameParameter;
|
||||
/// <summary> Gets a list of bikes reserved/ booked by acctive user from Copri.</summary>
|
||||
/// <returns>Request to query list of bikes occupied.</returns>
|
||||
public string GetBikesOccupied()
|
||||
=> "request=user_bikes_occupied&system=all&genkey=1" +
|
||||
AuthCookieParameter +
|
||||
UiIsoLanguageNameParameter;
|
||||
|
||||
/// <summary> Get list of stations from file. </summary>
|
||||
/// <returns>Request to query list of station.</returns>
|
||||
public string GetStations()
|
||||
=> "request=stations_available" +
|
||||
AuthCookieParameter +
|
||||
UiIsoLanguageNameParameter;
|
||||
/// <summary> Get list of stations from file. </summary>
|
||||
/// <returns>Request to query list of station.</returns>
|
||||
public string GetStations()
|
||||
=> "request=stations_available" +
|
||||
AuthCookieParameter +
|
||||
UiIsoLanguageNameParameter;
|
||||
|
||||
/// <summary> Gets reservation request (synonym: reservation == request == reservieren). </summary>
|
||||
/// <remarks> Operator specific call.</remarks>
|
||||
/// <param name="bikeId">Id of the bike to reserve.</param>
|
||||
/// <returns>Requst to reserve bike.</returns>
|
||||
public string DoReserve(string bikeId)
|
||||
=> "request=booking_request" +
|
||||
GetBikeIdParameter(bikeId) +
|
||||
AuthCookieParameter +
|
||||
UiIsoLanguageNameParameter;
|
||||
/// <summary> Gets reservation request (synonym: reservation == request == reservieren). </summary>
|
||||
/// <remarks> Operator specific call.</remarks>
|
||||
/// <param name="bikeId">Id of the bike to reserve.</param>
|
||||
/// <returns>Requst to reserve bike.</returns>
|
||||
public string DoReserve(string bikeId)
|
||||
=> "request=booking_request" +
|
||||
GetBikeIdParameter(bikeId) +
|
||||
AuthCookieParameter +
|
||||
UiIsoLanguageNameParameter;
|
||||
|
||||
/// <summary> Gets request to cancel reservation. </summary>
|
||||
/// <remarks> Operator specific call.</remarks>
|
||||
/// <param name="bikeId">Id of the bike to cancel reservation for.</param>
|
||||
/// <returns>Requst on cancel booking request.</returns>
|
||||
public string DoCancelReservation(string bikeId)
|
||||
=> "request=booking_cancel" +
|
||||
GetBikeIdParameter(bikeId) +
|
||||
AuthCookieParameter +
|
||||
UiIsoLanguageNameParameter;
|
||||
/// <summary> Gets request to cancel reservation. </summary>
|
||||
/// <remarks> Operator specific call.</remarks>
|
||||
/// <param name="bikeId">Id of the bike to cancel reservation for.</param>
|
||||
/// <returns>Requst on cancel booking request.</returns>
|
||||
public string DoCancelReservation(string bikeId)
|
||||
=> "request=booking_cancel" +
|
||||
GetBikeIdParameter(bikeId) +
|
||||
AuthCookieParameter +
|
||||
UiIsoLanguageNameParameter;
|
||||
|
||||
/// <summary> Request to get keys. </summary>
|
||||
/// <remarks> Operator specific call.</remarks>
|
||||
/// <param name="bikeId">Id of the bike to get keys for.</param>
|
||||
/// <returns>Request to get keys.</returns>
|
||||
public string CalculateAuthParameters(string bikeId)
|
||||
=> "request=booking_update" +
|
||||
GetBikeIdParameter(bikeId) +
|
||||
AuthCookieParameter +
|
||||
"&genkey=1" +
|
||||
UiIsoLanguageNameParameter;
|
||||
/// <summary> Request to get keys. </summary>
|
||||
/// <remarks> Operator specific call.</remarks>
|
||||
/// <param name="bikeId">Id of the bike to get keys for.</param>
|
||||
/// <returns>Request to get keys.</returns>
|
||||
public string CalculateAuthParameters(string bikeId)
|
||||
=> "request=booking_update" +
|
||||
GetBikeIdParameter(bikeId) +
|
||||
AuthCookieParameter +
|
||||
"&genkey=1" +
|
||||
UiIsoLanguageNameParameter;
|
||||
|
||||
/// <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>
|
||||
public string StartReturningBike(string bikeId)
|
||||
=> "request=booking_update" +
|
||||
GetBikeIdParameter(bikeId) +
|
||||
GetLockStateParameter(lock_state.locking) +
|
||||
AuthCookieParameter +
|
||||
UiIsoLanguageNameParameter;
|
||||
/// <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>
|
||||
public string StartReturningBike(string bikeId)
|
||||
=> "request=booking_update" +
|
||||
GetBikeIdParameter(bikeId) +
|
||||
GetLockStateParameter(lock_state.locking) +
|
||||
AuthCookieParameter +
|
||||
UiIsoLanguageNameParameter;
|
||||
|
||||
/// <summary> Gets the request for updating lock state for a booked bike. </summary>
|
||||
/// <remarks> Operator specific call.</remarks>
|
||||
/// <param name="bikeId">Id of the bike to update locking state for.</param>
|
||||
/// <param name="state">New locking state.</param>
|
||||
/// <returns>Request to update locking state.</returns>
|
||||
public string UpateLockingState(
|
||||
string bikeId,
|
||||
lock_state state,
|
||||
LocationDto geolocation,
|
||||
double batteryPercentage)
|
||||
=> "request=booking_update" +
|
||||
GetBikeIdParameter(bikeId) +
|
||||
GetLocationParameters(geolocation) +
|
||||
GetLockStateParameter(state) +
|
||||
GetBatteryPercentageParameters(batteryPercentage) +
|
||||
AuthCookieParameter +
|
||||
UiIsoLanguageNameParameter;
|
||||
/// <summary> Gets the request for updating lock state for a booked bike. </summary>
|
||||
/// <remarks> Operator specific call.</remarks>
|
||||
/// <param name="bikeId">Id of the bike to update locking state for.</param>
|
||||
/// <param name="state">New locking state.</param>
|
||||
/// <returns>Request to update locking state.</returns>
|
||||
public string UpateLockingState(
|
||||
string bikeId,
|
||||
lock_state state,
|
||||
LocationDto geolocation,
|
||||
double batteryPercentage)
|
||||
=> "request=booking_update" +
|
||||
GetBikeIdParameter(bikeId) +
|
||||
GetLocationParameters(geolocation) +
|
||||
GetLockStateParameter(state) +
|
||||
GetBatteryPercentageParameters(batteryPercentage) +
|
||||
AuthCookieParameter +
|
||||
UiIsoLanguageNameParameter;
|
||||
|
||||
|
||||
/// <summary> Gets booking request request (synonym: booking == renting == mieten). </summary>
|
||||
/// <remarks> Operator specific call.</remarks>
|
||||
/// <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>
|
||||
public string DoBook(string bikeId, Guid guid, double batteryPercentage)
|
||||
=> "request=booking_update" +
|
||||
GetBikeIdParameter(bikeId) +
|
||||
AuthCookieParameter +
|
||||
$"&Ilockit_GUID={guid}" +
|
||||
"&state=occupied" +
|
||||
GetLockStateParameter(lock_state.unlocked) +
|
||||
GetBatteryPercentageParameters(batteryPercentage) +
|
||||
UiIsoLanguageNameParameter;
|
||||
/// <summary> Gets booking request request (synonym: booking == renting == mieten). </summary>
|
||||
/// <remarks> Operator specific call.</remarks>
|
||||
/// <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>
|
||||
public string DoBook(string bikeId, Guid guid, double batteryPercentage)
|
||||
=> "request=booking_update" +
|
||||
GetBikeIdParameter(bikeId) +
|
||||
AuthCookieParameter +
|
||||
$"&Ilockit_GUID={guid}" +
|
||||
"&state=occupied" +
|
||||
GetLockStateParameter(lock_state.unlocked) +
|
||||
GetBatteryPercentageParameters(batteryPercentage) +
|
||||
UiIsoLanguageNameParameter;
|
||||
|
||||
/// <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>
|
||||
public string BookAvailableAndStartOpening(string bikeId)
|
||||
=> "request=booking_request" +
|
||||
GetBikeIdParameter(bikeId) +
|
||||
AuthCookieParameter +
|
||||
"&state=occupied" +
|
||||
GetLockStateParameter(lock_state.unlocking) +
|
||||
UiIsoLanguageNameParameter;
|
||||
/// <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>
|
||||
public string BookAvailableAndStartOpening(string bikeId)
|
||||
=> "request=booking_request" +
|
||||
GetBikeIdParameter(bikeId) +
|
||||
AuthCookieParameter +
|
||||
"&state=occupied" +
|
||||
GetLockStateParameter(lock_state.unlocking) +
|
||||
UiIsoLanguageNameParameter;
|
||||
|
||||
/// <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>
|
||||
public string BookReservedAndStartOpening(string bikeId)
|
||||
=> "request=booking_update" +
|
||||
GetBikeIdParameter(bikeId) +
|
||||
AuthCookieParameter +
|
||||
"&state=occupied" +
|
||||
GetLockStateParameter(lock_state.unlocking) +
|
||||
UiIsoLanguageNameParameter;
|
||||
/// <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>
|
||||
public string BookReservedAndStartOpening(string bikeId)
|
||||
=> "request=booking_update" +
|
||||
GetBikeIdParameter(bikeId) +
|
||||
AuthCookieParameter +
|
||||
"&state=occupied" +
|
||||
GetLockStateParameter(lock_state.unlocking) +
|
||||
UiIsoLanguageNameParameter;
|
||||
|
||||
/// <summary> Gets request for returning the bike. </summary>
|
||||
/// <remarks> Operator specific call.</remarks>
|
||||
/// <param name="bikeId">Id of bike to return.</param>
|
||||
/// <param name="geolocation">Geolocation of lock when returning bike.</param>
|
||||
/// <returns>Requst on returning request.</returns>
|
||||
public string DoReturn(string bikeId, LocationDto geolocation, ISmartDevice smartDevice)
|
||||
=> "request=booking_update" +
|
||||
GetBikeIdParameter(bikeId) +
|
||||
AuthCookieParameter +
|
||||
"&state=available" +
|
||||
GetLocationParameters(geolocation) +
|
||||
GetLockStateParameter(lock_state.locked) +
|
||||
GetSmartDeviceParameters(smartDevice) +
|
||||
GetLog() +
|
||||
UiIsoLanguageNameParameter;
|
||||
/// <summary> Gets request for returning the bike. </summary>
|
||||
/// <remarks> Operator specific call.</remarks>
|
||||
/// <param name="bikeId">Id of bike to return.</param>
|
||||
/// <param name="geolocation">Geolocation of lock when returning bike.</param>
|
||||
/// <returns>Requst on returning request.</returns>
|
||||
public string DoReturn(string bikeId, LocationDto geolocation, ISmartDevice smartDevice)
|
||||
=> "request=booking_update" +
|
||||
GetBikeIdParameter(bikeId) +
|
||||
AuthCookieParameter +
|
||||
"&state=available" +
|
||||
GetLocationParameters(geolocation) +
|
||||
GetLockStateParameter(lock_state.locked) +
|
||||
GetSmartDeviceParameters(smartDevice) +
|
||||
GetLog() +
|
||||
UiIsoLanguageNameParameter;
|
||||
|
||||
|
||||
/// <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 corpi.</returns>
|
||||
public string ReturnAndStartClosing(string bikeId, ISmartDevice smartDevice)
|
||||
=> "request=booking_update" +
|
||||
GetBikeIdParameter(bikeId) +
|
||||
AuthCookieParameter +
|
||||
"&state=available" +
|
||||
GetLockStateParameter(lock_state.locking) +
|
||||
GetSmartDeviceParameters(smartDevice) +
|
||||
UiIsoLanguageNameParameter;
|
||||
/// <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 corpi.</returns>
|
||||
public string ReturnAndStartClosing(string bikeId, ISmartDevice smartDevice)
|
||||
=> "request=booking_update" +
|
||||
GetBikeIdParameter(bikeId) +
|
||||
AuthCookieParameter +
|
||||
"&state=available" +
|
||||
GetLockStateParameter(lock_state.locking) +
|
||||
GetSmartDeviceParameters(smartDevice) +
|
||||
UiIsoLanguageNameParameter;
|
||||
|
||||
/// <summary> Gets submit feedback request. </summary>
|
||||
/// <param name="bikeId">Id of the bike to return.</param>
|
||||
/// <param name="message">General purpose message or error description.</param>
|
||||
/// <param name="isBikeBroken">True if bike is broken.</param>
|
||||
/// <returns>Submit feedback request.</returns>
|
||||
public string DoSubmitFeedback(
|
||||
string bikeId,
|
||||
int? currentChargeBars = null,
|
||||
string message = null,
|
||||
bool isBikeBroken = false)
|
||||
{
|
||||
string GetIsBikeBroken()
|
||||
=> isBikeBroken ? "&bike_broken=1" : string.Empty;
|
||||
/// <summary> Gets submit feedback request. </summary>
|
||||
/// <param name="bikeId">Id of the bike to return.</param>
|
||||
/// <param name="message">General purpose message or error description.</param>
|
||||
/// <param name="isBikeBroken">True if bike is broken.</param>
|
||||
/// <returns>Submit feedback request.</returns>
|
||||
public string DoSubmitFeedback(
|
||||
string bikeId,
|
||||
int? currentChargeBars = null,
|
||||
string message = null,
|
||||
bool isBikeBroken = false)
|
||||
{
|
||||
string GetIsBikeBroken()
|
||||
=> isBikeBroken ? "&bike_broken=1" : string.Empty;
|
||||
|
||||
string GetMessage()
|
||||
=> !string.IsNullOrEmpty(message) ? $"&message={WebUtility.UrlEncode(message)}" : string.Empty;
|
||||
string GetMessage()
|
||||
=> !string.IsNullOrEmpty(message) ? $"&message={WebUtility.UrlEncode(message)}" : string.Empty;
|
||||
|
||||
string GetCurrentChargeBars()
|
||||
=> currentChargeBars != null ? $"&charge_current_bars={currentChargeBars.Value}" : string.Empty;
|
||||
string GetCurrentChargeBars()
|
||||
=> currentChargeBars != null ? $"&charge_current_bars={currentChargeBars.Value}" : string.Empty;
|
||||
|
||||
return "request=user_feedback" +
|
||||
GetBikeIdParameter(bikeId) +
|
||||
GetCurrentChargeBars() +
|
||||
GetIsBikeBroken() +
|
||||
GetMessage() +
|
||||
AuthCookieParameter +
|
||||
UiIsoLanguageNameParameter;
|
||||
}
|
||||
return "request=user_feedback" +
|
||||
GetBikeIdParameter(bikeId) +
|
||||
GetCurrentChargeBars() +
|
||||
GetIsBikeBroken() +
|
||||
GetMessage() +
|
||||
AuthCookieParameter +
|
||||
UiIsoLanguageNameParameter;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets request for submiting mini survey to copri server.
|
||||
/// </summary>
|
||||
/// <param name="answers">Collection of answers.</param>
|
||||
public string DoSubmitMiniSurvey(IDictionary<string, string> answers)
|
||||
{
|
||||
// Remove entires which invalid keys or values.
|
||||
var validAnsers = answers?.Where(x => !string.IsNullOrEmpty(x.Key?.Trim()) && !string.IsNullOrEmpty(x.Value?.Trim()));
|
||||
/// <summary>
|
||||
/// Gets request for submiting mini survey to copri server.
|
||||
/// </summary>
|
||||
/// <param name="answers">Collection of answers.</param>
|
||||
public string DoSubmitMiniSurvey(IDictionary<string, string> answers)
|
||||
{
|
||||
// Remove entires which invalid keys or values.
|
||||
var validAnsers = answers?.Where(x => !string.IsNullOrEmpty(x.Key?.Trim()) && !string.IsNullOrEmpty(x.Value?.Trim()));
|
||||
|
||||
// Create quersy
|
||||
if (validAnsers == null || validAnsers.Count() <= 0)
|
||||
return "request=user_minianswer" +
|
||||
AuthCookieParameter +
|
||||
UiIsoLanguageNameParameter;
|
||||
// Create quersy
|
||||
if (validAnsers == null || validAnsers.Count() <= 0)
|
||||
return "request=user_minianswer" +
|
||||
AuthCookieParameter +
|
||||
UiIsoLanguageNameParameter;
|
||||
|
||||
return "request=user_minianswer" +
|
||||
$"&{string.Join("&", validAnsers.Select(x => $"{x.Key}={WebUtility.UrlEncode(x.Value)}"))}" +
|
||||
AuthCookieParameter +
|
||||
UiIsoLanguageNameParameter;
|
||||
}
|
||||
return "request=user_minianswer" +
|
||||
$"&{string.Join("&", validAnsers.Select(x => $"{x.Key}={WebUtility.UrlEncode(x.Value)}"))}" +
|
||||
AuthCookieParameter +
|
||||
UiIsoLanguageNameParameter;
|
||||
}
|
||||
|
||||
private static string GetBikeIdParameter(string bikeId)
|
||||
=> $"&bike={bikeId}";
|
||||
private static string GetBikeIdParameter(string bikeId)
|
||||
=> $"&bike={bikeId}";
|
||||
|
||||
private static string GetLockStateParameter(lock_state lockState)
|
||||
=> $"&lock_state={lockState}";
|
||||
private static string GetLockStateParameter(lock_state lockState)
|
||||
=> $"&lock_state={lockState}";
|
||||
|
||||
private static string GetBatteryPercentageParameters(double batteryPercentage) => !double.IsNaN(batteryPercentage)
|
||||
? $"&voltage={batteryPercentage.ToString(CultureInfo.InvariantCulture)}"
|
||||
: string.Empty;
|
||||
private static string GetBatteryPercentageParameters(double batteryPercentage) => !double.IsNaN(batteryPercentage)
|
||||
? $"&voltage={batteryPercentage.ToString(CultureInfo.InvariantCulture)}"
|
||||
: string.Empty;
|
||||
|
||||
/// <summary> Gets the geolocation parameter. </summary>
|
||||
/// <param name="geolocation">Geolocation or null.</param>
|
||||
private static string GetLocationParameters(LocationDto geolocation)
|
||||
{
|
||||
if (geolocation == null)
|
||||
return string.Empty;
|
||||
/// <summary> Gets the geolocation parameter. </summary>
|
||||
/// <param name="geolocation">Geolocation or null.</param>
|
||||
private static string GetLocationParameters(LocationDto geolocation)
|
||||
{
|
||||
if (geolocation == null)
|
||||
return string.Empty;
|
||||
|
||||
if (geolocation.Accuracy == null)
|
||||
return $"&gps={geolocation.Latitude.ToString(CultureInfo.InvariantCulture)},{geolocation.Longitude.ToString(CultureInfo.InvariantCulture)}&gps_age={geolocation.Age.TotalSeconds}";
|
||||
if (geolocation.Accuracy == null)
|
||||
return $"&gps={geolocation.Latitude.ToString(CultureInfo.InvariantCulture)},{geolocation.Longitude.ToString(CultureInfo.InvariantCulture)}&gps_age={geolocation.Age.TotalSeconds}";
|
||||
|
||||
return $"&gps={geolocation.Latitude.ToString(CultureInfo.InvariantCulture)},{geolocation.Longitude.ToString(CultureInfo.InvariantCulture)}&gps_accuracy={geolocation.Accuracy.Value.ToString(CultureInfo.InvariantCulture)}&gps_age={geolocation.Age.TotalSeconds}";
|
||||
}
|
||||
return $"&gps={geolocation.Latitude.ToString(CultureInfo.InvariantCulture)},{geolocation.Longitude.ToString(CultureInfo.InvariantCulture)}&gps_accuracy={geolocation.Accuracy.Value.ToString(CultureInfo.InvariantCulture)}&gps_age={geolocation.Age.TotalSeconds}";
|
||||
}
|
||||
|
||||
/// <summary> Gets the geolocation parameter. </summary>
|
||||
/// <param name="geolocation">Geolocation or null.</param>
|
||||
private static string GetSmartDeviceParameters(ISmartDevice smartDevice)
|
||||
=> smartDevice != null
|
||||
? $"{(!string.IsNullOrEmpty(smartDevice.Manufacturer) ? $"&user_device_manufaturer={smartDevice.Manufacturer})" : string.Empty)}" +
|
||||
$"{(!string.IsNullOrEmpty(smartDevice.Model) ? $"&user_device_model={smartDevice.Model}" : string.Empty)}" +
|
||||
$"{(!string.IsNullOrEmpty(smartDevice.Platform.ToString()) ? $"&user_device_platform={smartDevice.Platform.ToString()}" : string.Empty)}" +
|
||||
$"{(!string.IsNullOrEmpty(smartDevice.VersionText) ? $"&user_device_version={smartDevice.VersionText}" : string.Empty)}" +
|
||||
$"{(!string.IsNullOrEmpty(smartDevice.Identifier) ? $"&user_device_id={smartDevice.Identifier}" : string.Empty)}"
|
||||
: string.Empty;
|
||||
/// <summary> Gets the geolocation parameter. </summary>
|
||||
/// <param name="geolocation">Geolocation or null.</param>
|
||||
private static string GetSmartDeviceParameters(ISmartDevice smartDevice)
|
||||
=> smartDevice != null
|
||||
? $"{(!string.IsNullOrEmpty(smartDevice.Manufacturer) ? $"&user_device_manufaturer={smartDevice.Manufacturer})" : string.Empty)}" +
|
||||
$"{(!string.IsNullOrEmpty(smartDevice.Model) ? $"&user_device_model={smartDevice.Model}" : string.Empty)}" +
|
||||
$"{(!string.IsNullOrEmpty(smartDevice.Platform.ToString()) ? $"&user_device_platform={smartDevice.Platform.ToString()}" : string.Empty)}" +
|
||||
$"{(!string.IsNullOrEmpty(smartDevice.VersionText) ? $"&user_device_version={smartDevice.VersionText}" : string.Empty)}" +
|
||||
$"{(!string.IsNullOrEmpty(smartDevice.Identifier) ? $"&user_device_id={smartDevice.Identifier}" : string.Empty)}"
|
||||
: string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets logging entries from serilog.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private static string GetLog()
|
||||
{
|
||||
var messages = string.Join("\n", MemoryStackSink.PopAllMessages());
|
||||
return !string.IsNullOrEmpty(messages)
|
||||
? "&app_debug=" + WebUtility.UrlEncode(string.Join("\n", messages))
|
||||
: string.Empty;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets logging entries from serilog.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private static string GetLog()
|
||||
{
|
||||
var messages = string.Join("\n", MemoryStackSink.PopAllMessages());
|
||||
return !string.IsNullOrEmpty(messages)
|
||||
? "&app_debug=" + WebUtility.UrlEncode(string.Join("\n", messages))
|
||||
: string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue