mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-06-22 05:47:28 +02:00
Version 3.0.356
This commit is contained in:
parent
d23aff6daf
commit
5980410182
48 changed files with 242 additions and 362 deletions
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TINK.Model.Bikes.BikeInfoNS.BluetoothLock;
|
||||
using TINK.Model.Connector;
|
||||
using TINK.Model.Device;
|
||||
|
||||
namespace TINK.Repository.Request
|
||||
|
@ -79,8 +80,9 @@ namespace TINK.Repository.Request
|
|||
/// <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);
|
||||
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>
|
||||
|
|
|
@ -2,6 +2,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using TINK.Model.Bikes.BikeInfoNS.BluetoothLock;
|
||||
using TINK.Model.Connector;
|
||||
using TINK.Model.Device;
|
||||
using TINK.Repository.Exception;
|
||||
|
||||
|
@ -109,7 +110,7 @@ namespace TINK.Repository.Request
|
|||
public string UpateLockingState(string bikeId, lock_state state, LocationDto geolocation, double batteryPercentage, IVersionInfo versionInfo)
|
||||
=> throw new NotSupportedException();
|
||||
|
||||
public string DoBook(string bikeId, Guid guid, double batteryPercentage)
|
||||
public string DoBook(string bikeId, Guid guid, double batteryPercentage, LockingAction? nextAction = null)
|
||||
=> throw new NotSupportedException();
|
||||
|
||||
/// <summary> Gets the request to book and start opening the bike (synonym: booking == renting == mieten). </summary>
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
|
||||
|
||||
using TINK.Model.Connector;
|
||||
|
||||
namespace TINK.Repository.Request
|
||||
{
|
||||
public static class RequestBuilderHelper
|
||||
|
@ -12,5 +14,20 @@ namespace TINK.Repository.Request
|
|||
=> !string.IsNullOrEmpty(uiIsoLangugageName)
|
||||
? $"&lang={uiIsoLangugageName}"
|
||||
: string.Empty;
|
||||
|
||||
public static lock_state? GetLockState(this LockingAction? action)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
case LockingAction.Open:
|
||||
return lock_state.unlocking;
|
||||
|
||||
case LockingAction.Close:
|
||||
return lock_state.locking;
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ using System.Globalization;
|
|||
using System.Linq;
|
||||
using System.Net;
|
||||
using TINK.Model.Bikes.BikeInfoNS.BluetoothLock;
|
||||
using TINK.Model.Connector;
|
||||
using TINK.Model.Device;
|
||||
using TINK.Repository.Exception;
|
||||
using TINK.Services.Logging;
|
||||
|
@ -153,14 +154,15 @@ namespace TINK.Repository.Request
|
|||
/// <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>
|
||||
public string DoBook(string bikeId, Guid guid, double batteryPercentage)
|
||||
public string DoBook(string bikeId, Guid guid, double batteryPercentage, LockingAction? nextAction = null)
|
||||
=> "request=booking_update" +
|
||||
GetBikeIdParameter(bikeId) +
|
||||
AuthCookieParameter +
|
||||
$"&Ilockit_GUID={guid}" +
|
||||
"&state=occupied" +
|
||||
GetLockStateParameter(lock_state.unlocked) +
|
||||
GetLockStateParameter(nextAction.GetLockState()) +
|
||||
GetBatteryPercentageParameters(batteryPercentage) +
|
||||
UiIsoLanguageNameParameter;
|
||||
|
||||
|
@ -269,9 +271,12 @@ namespace TINK.Repository.Request
|
|||
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)
|
||||
=> lockState.HasValue ? $"&lock_state={lockState}" : string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the battery level percentage parameter if percentage is not NaN an empty string otherwise.
|
||||
/// </summary>
|
||||
private static string GetBatteryPercentageParameters(double batteryPercentage) => !double.IsNaN(batteryPercentage)
|
||||
? $"&voltage={batteryPercentage.ToString(CultureInfo.InvariantCulture)}"
|
||||
: string.Empty;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue