Version 3.0.356

This commit is contained in:
Oliver Hauff 2022-12-27 21:08:09 +01:00
parent d23aff6daf
commit 5980410182
48 changed files with 242 additions and 362 deletions

View file

@ -7,6 +7,7 @@ using System.Text;
using System.Threading.Tasks;
using Serilog;
using TINK.Model.Bikes.BikeInfoNS.BluetoothLock;
using TINK.Model.Connector;
using TINK.Model.Device;
using TINK.Model.Logging;
using TINK.Repository.Exception;
@ -181,19 +182,21 @@ namespace TINK.Repository
UserAgent);
/// <summary> Gets booking request request. </summary>
/// <param name="operatorUri">Holds the uri of the operator or null, in case of single operator setup.</param>
/// <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="operatorUri">Holds the uri of the operator or null, in case of single operator setup.</param>
/// <param name="nextAction">If not null next locking action which is performed after booking.</param>
/// <returns>Requst on booking request.</returns>
public async Task<ReservationBookingResponse> DoBookAsync(
Uri operatorUri,
string bikeId,
Guid guid,
double batteryPercentage,
Uri operatorUri)
double batteryPercentage,
LockingAction? nextAction = null)
=> await DoBookAsync(
operatorUri?.AbsoluteUri ?? m_oCopriHost.AbsoluteUri,
requestBuilder.DoBook(bikeId, guid, batteryPercentage),
requestBuilder.DoBook(bikeId, guid, batteryPercentage, nextAction),
UserAgent);
/// <summary> Books a bike and starts opening bike. </summary>

View file

@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using TINK.Model.Bikes.BikeInfoNS.BluetoothLock;
using TINK.Model.Connector;
using TINK.Model.Device;
using TINK.Repository.Request;
using TINK.Repository.Response;
@ -1640,7 +1641,7 @@ namespace TINK.Repository
double batteryLevel,
IVersionInfo versionInfo) => null;
public Task<ReservationBookingResponse> DoBookAsync(string bikeId, Guid guid, double batteryPercentage, Uri operatorUri)
public Task<ReservationBookingResponse> DoBookAsync(Uri operatorUri, string bikeId, Guid guid, double batteryPercentage, LockingAction? nextAction = null)
=> null;
public Task<ReservationBookingResponse> BookAvailableAndStartOpeningAsync(

View file

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Threading.Tasks;
using MonkeyCache.FileStore;
using TINK.Model.Bikes.BikeInfoNS.BluetoothLock;
using TINK.Model.Connector;
using TINK.Model.Device;
using TINK.Model.Services.CopriApi;
using TINK.Repository.Request;
@ -176,7 +177,7 @@ namespace TINK.Repository
IVersionInfo versionInfo)
=> throw new System.Exception("Aktualisierung des Schlossstatuses im Offlinemodus nicht möglich!");
public Task<ReservationBookingResponse> DoBookAsync(string bikeId, Guid guid, double batteryPercentage, Uri operatorUri)
public Task<ReservationBookingResponse> DoBookAsync(Uri operatorUri, string bikeId, Guid guid, double batteryPercentage, LockingAction? nextAction = null)
=> throw new System.Exception("Buchung im Offlinemodus nicht möglich!");
/// <summary> Books a bike and starts opening bike. </summary>

View file

@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using TINK.Model.Bikes.BikeInfoNS.BluetoothLock;
using TINK.Model.Connector;
using TINK.Model.Device;
using TINK.Repository.Request;
using TINK.Repository.Response;
@ -74,16 +75,18 @@ namespace TINK.Repository
IVersionInfo versionInfo = null);
/// <summary> Books a bluetooth bike. </summary>
/// <param name="operatorUri">Holds the uri of the operator or null, in case of single operator setup.</param>
/// <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="operatorUri">Holds the uri of the operator or null, in case of single operator setup.</param>
/// <param name="nextAction">If not null next locking action which is performed after booking.</param>
/// <returns>Response on booking request.</returns>
Task<ReservationBookingResponse> DoBookAsync(
Uri operatorUri,
string bikeId,
Guid guid,
double batteryPercentage,
Uri operatorUri);
double batteryPercentage,
LockingAction? nextAction = null);
/// <summary> Books a bike and starts opening bike. </summary>
/// <param name="bikeId">Id of the bike to book.</param>

View file

@ -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>

View file

@ -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>

View file

@ -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;
}
}
}
}

View file

@ -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;