mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-06-22 05:47:28 +02:00
Code updated to 3.0.238
This commit is contained in:
parent
3302d80678
commit
9c6a1fa92b
257 changed files with 7763 additions and 2861 deletions
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using TINK.Model.Device;
|
||||
|
||||
namespace TINK.Model.Repository.Request
|
||||
namespace TINK.Repository.Request
|
||||
{
|
||||
/// <summary> Defines members to create requests.</summary>
|
||||
public interface IRequestBuilder
|
||||
|
@ -41,17 +42,17 @@ namespace TINK.Model.Repository.Request
|
|||
/// <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(int bikeId);
|
||||
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(int bikeId);
|
||||
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 CalculateAuthKeys(int bikeId);
|
||||
string CalculateAuthParameters(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>
|
||||
|
@ -59,7 +60,7 @@ namespace TINK.Model.Repository.Request
|
|||
/// <param name="state">New locking state.</param>
|
||||
/// <returns>Request to update locking state.</returns>
|
||||
string UpateLockingState(
|
||||
int bikeId,
|
||||
string bikeId,
|
||||
LocationDto location,
|
||||
lock_state state,
|
||||
double batteryPercentage);
|
||||
|
@ -69,20 +70,21 @@ namespace TINK.Model.Repository.Request
|
|||
/// <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(int bikeId, Guid guid, double batteryPercentage);
|
||||
string DoBook(string bikeId, Guid guid, double batteryPercentage);
|
||||
|
||||
/// <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(int bikeId, LocationDto location);
|
||||
string DoReturn(string bikeId, LocationDto location, 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="message">General purpose message or error description.</param>
|
||||
/// <param name="isBikeBroken">True if bike is broken.</param>
|
||||
string DoSubmitFeedback(string message = null, bool isBikeBroken = false);
|
||||
string DoSubmitFeedback(string bikeId, string message = null, bool isBikeBroken = false);
|
||||
}
|
||||
|
||||
/// <summary> Copri locking states</summary>
|
||||
|
@ -92,6 +94,7 @@ namespace TINK.Model.Repository.Request
|
|||
unlocked
|
||||
}
|
||||
|
||||
/// <summary> Holds lockation info.</summary>
|
||||
public class LocationDto
|
||||
{
|
||||
public double Latitude { get; private set; }
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
using System;
|
||||
using System.Net;
|
||||
using TINK.Model.Repository.Exception;
|
||||
using TINK.Model.Device;
|
||||
using TINK.Repository.Exception;
|
||||
|
||||
namespace TINK.Model.Repository.Request
|
||||
namespace TINK.Repository.Request
|
||||
{
|
||||
/// <summary> Creates requests if no user is logged in.</summary>
|
||||
public class RequestBuilder : IRequestBuilder
|
||||
|
@ -80,32 +81,34 @@ namespace TINK.Model.Repository.Request
|
|||
public string GetBikesOccupied() => throw new NotSupportedException();
|
||||
|
||||
/// <summary> Gets booking request response. </summary>
|
||||
/// <param name="p_iBikeId">Id of the bike to book.</param>
|
||||
/// <param name="bikeId">Id of the bike to book.</param>
|
||||
/// <returns>Response on booking request.</returns>
|
||||
public string DoReserve(int p_iBikeId) => throw new NotSupportedException();
|
||||
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(int p_iBikeId) => throw new NotSupportedException();
|
||||
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 CalculateAuthKeys(int bikeId) => throw new NotSupportedException();
|
||||
public string CalculateAuthParameters(string bikeId) => throw new NotSupportedException();
|
||||
|
||||
public string UpateLockingState(int bikeId, LocationDto geolocation, lock_state state, double batteryPercentage)
|
||||
public string UpateLockingState(string bikeId, LocationDto geolocation, lock_state state, double batteryPercentage)
|
||||
=> throw new NotSupportedException();
|
||||
|
||||
public string DoBook(int bikeId, Guid guid, double batteryPercentage) => throw new NotSupportedException();
|
||||
public string DoBook(string bikeId, Guid guid, double batteryPercentage) => throw new NotSupportedException();
|
||||
|
||||
public string DoReturn(int bikeId, LocationDto geolocation) => throw new NotSupportedException();
|
||||
public string DoReturn(string bikeId, LocationDto geolocation, 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,
|
||||
string message = null,
|
||||
bool isBikeBroken = false) => throw new NotSupportedException();
|
||||
}
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
using System;
|
||||
using System.Globalization;
|
||||
using System.Net;
|
||||
using TINK.Model.Repository.Exception;
|
||||
using TINK.Model.Device;
|
||||
using TINK.Repository.Exception;
|
||||
|
||||
namespace TINK.Model.Repository.Request
|
||||
namespace TINK.Repository.Request
|
||||
{
|
||||
/// <summary> Creates requests if a user is logged in.</summary>
|
||||
public class RequestBuilderLoggedIn : IRequestBuilder
|
||||
|
@ -75,21 +76,21 @@ namespace TINK.Model.Repository.Request
|
|||
/// <remarks> Operator specific call.</remarks>
|
||||
/// <param name="bikeId">Id of the bike to reserve.</param>
|
||||
/// <returns>Requst to reserve bike.</returns>
|
||||
public string DoReserve(int bikeId)
|
||||
public string DoReserve(string bikeId)
|
||||
=> $"request=booking_request&bike={bikeId}&authcookie={SessionCookie}{MerchantId}";
|
||||
|
||||
/// <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(int p_iBikeId)
|
||||
public string DoCancelReservation(string p_iBikeId)
|
||||
=> $"request=booking_cancel&bike={p_iBikeId}&authcookie={SessionCookie}{MerchantId}";
|
||||
|
||||
/// <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 CalculateAuthKeys(int bikeId)
|
||||
public string CalculateAuthParameters(string bikeId)
|
||||
=> $"request=booking_update&bike={bikeId}&authcookie={SessionCookie}{MerchantId}&genkey=1";
|
||||
|
||||
/// <summary> Gets the request for updating lock state for a booked bike. </summary>
|
||||
|
@ -97,9 +98,9 @@ namespace TINK.Model.Repository.Request
|
|||
/// <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(int bikeId, LocationDto geolocation, lock_state state, double batteryPercentage)
|
||||
public string UpateLockingState(string bikeId, LocationDto geolocation, lock_state state, double batteryPercentage)
|
||||
{
|
||||
return $"request=booking_update&bike={bikeId}{GetLocationKey(geolocation)}&lock_state={state}{GetBatteryPercentageKey(batteryPercentage)}&authcookie={SessionCookie}{MerchantId}";
|
||||
return $"request=booking_update&bike={bikeId}{GetLocationParameters(geolocation)}&lock_state={state}{GetBatteryPercentageParameters(batteryPercentage)}&authcookie={SessionCookie}{MerchantId}";
|
||||
}
|
||||
|
||||
/// <summary> Gets booking request request (synonym: booking == renting == mieten). </summary>
|
||||
|
@ -108,55 +109,65 @@ namespace TINK.Model.Repository.Request
|
|||
/// <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(int bikeId, Guid guid, double batteryPercentage)
|
||||
=> $"request=booking_update&bike={bikeId}&authcookie={SessionCookie}{MerchantId}&Ilockit_GUID={guid}&state=occupied&lock_state=unlocked{GetBatteryPercentageKey(batteryPercentage)}";
|
||||
public string DoBook(string bikeId, Guid guid, double batteryPercentage)
|
||||
=> $"request=booking_update&bike={bikeId}&authcookie={SessionCookie}{MerchantId}&Ilockit_GUID={guid}&state=occupied&lock_state=unlocked{GetBatteryPercentageParameters(batteryPercentage)}";
|
||||
|
||||
/// <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(int bikeId, LocationDto geolocation)
|
||||
public string DoReturn(string bikeId, LocationDto geolocation, ISmartDevice smartDevice)
|
||||
{
|
||||
return $"request=booking_update&bike={bikeId}&authcookie={SessionCookie}{MerchantId}&state=available{GetLocationKey(geolocation)}&lock_state=locked";
|
||||
return $"request=booking_update" +
|
||||
$"&bike={bikeId}" +
|
||||
$"&authcookie={SessionCookie}{MerchantId}" +
|
||||
$"&state=available" +
|
||||
$"{GetLocationParameters(geolocation)}" +
|
||||
$"&lock_state=locked" +
|
||||
$"{GetSmartDeviceParameters(smartDevice)}";
|
||||
}
|
||||
|
||||
/// <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,
|
||||
string message = null,
|
||||
bool isBikeBroken = false)
|
||||
{
|
||||
if (string.IsNullOrEmpty(message) && !isBikeBroken)
|
||||
{
|
||||
// User just acknoledged biked returned message.
|
||||
return "request=user_feedback";
|
||||
return $"request=user_feedback&bike={bikeId}&authcookie={SessionCookie}{MerchantId}";
|
||||
}
|
||||
|
||||
if (isBikeBroken == false)
|
||||
{
|
||||
// Bike is ok and user entered a feedback message.
|
||||
return $"request=user_feedback&message={WebUtility.UrlEncode(message)}";
|
||||
return $"request=user_feedback&bike={bikeId}&message={WebUtility.UrlEncode(message)}&authcookie={SessionCookie}{MerchantId}";
|
||||
}
|
||||
|
||||
|
||||
if (string.IsNullOrEmpty(message))
|
||||
{
|
||||
// User just marked bike as broken without comment.
|
||||
return $"request=user_feedback&bike_broken=1";
|
||||
return $"request=user_feedback&bike={bikeId}&bike_broken=1&authcookie={SessionCookie}{MerchantId}";
|
||||
}
|
||||
|
||||
// Bike is marked as broken and user added a comment.
|
||||
return $"request=user_feedback&bike_broken=1&message={WebUtility.UrlEncode(message)}";
|
||||
return $"request=user_feedback&bike={bikeId}&bike_broken=1&message={WebUtility.UrlEncode(message)}&authcookie={SessionCookie}{MerchantId}";
|
||||
}
|
||||
|
||||
private string GetBatteryPercentageKey(double batteryPercentage) => !double.IsNaN(batteryPercentage)
|
||||
private string GetBatteryPercentageParameters(double batteryPercentage) => !double.IsNaN(batteryPercentage)
|
||||
? $"&voltage={batteryPercentage.ToString(CultureInfo.InvariantCulture)}"
|
||||
: string.Empty;
|
||||
|
||||
private string GetLocationKey(LocationDto geolocation)
|
||||
/// <summary> Gets the geolocation parameter. </summary>
|
||||
/// <param name="geolocation">Geolocation or null.</param>
|
||||
private string GetLocationParameters(LocationDto geolocation)
|
||||
{
|
||||
if (geolocation == null)
|
||||
return string.Empty;
|
||||
|
@ -166,5 +177,16 @@ namespace TINK.Model.Repository.Request
|
|||
|
||||
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 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.PlatformText) ? $"&user_device_platform={smartDevice.PlatformText}" : 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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue