Version 3.0.290

This commit is contained in:
Oliver Hauff 2022-04-10 17:38:34 +02:00
parent af3c20ea1c
commit ad3cdbcadf
231 changed files with 14555 additions and 7798 deletions

View file

@ -158,6 +158,19 @@ namespace TINK.Repository
requestBuilder.CalculateAuthParameters(bikeId),
UserAgent);
/// <summary> Notifies COPRI about start of returning sequence. </summary>
/// <remarks> Operator specific call.</remarks>
/// <param name="bikeId">Id of the bike to return.</param>+
/// <param name="operatorUri">Holds the uri of the operator or null, in case of single operator setup.</param>
/// <returns>Response on notification about start of returning sequence.</returns>
public async Task<ResponseBase> StartReturningBike(
string bikeId,
Uri operatorUri)
=> await DoStartReturningBike(
operatorUri?.AbsoluteUri ?? m_oCopriHost.AbsoluteUri,
requestBuilder.StartReturningBike(bikeId),
UserAgent);
/// <summary> Updates 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.</param>
@ -170,13 +183,11 @@ namespace TINK.Repository
LocationDto location,
lock_state state,
double batteryLevel,
Uri operatorUri)
{
return await DoUpdateLockingStateAsync(
operatorUri?.AbsoluteUri ?? m_oCopriHost.AbsoluteUri,
requestBuilder.UpateLockingState(bikeId, location, state, batteryLevel),
UserAgent);
}
Uri operatorUri)=>
await DoUpdateLockingStateAsync(
operatorUri?.AbsoluteUri ?? m_oCopriHost.AbsoluteUri,
requestBuilder.UpateLockingState(bikeId, location, state, batteryLevel),
UserAgent);
/// <summary> Gets booking request request. </summary>
/// <param name="bikeId">Id of the bike to book.</param>
@ -547,34 +558,67 @@ namespace TINK.Repository
#endif
}
public static async Task<ReservationBookingResponse> DoUpdateLockingStateAsync(
public static async Task<ResponseBase> DoStartReturningBike(
string copriHost,
string command,
string agent = null)
{
#if !WINDOWS_UWP
string l_oBikesAvaialbeResponse;
string response;
try
{
l_oBikesAvaialbeResponse = await PostAsync(copriHost, command, agent);
response = await PostAsync(copriHost, command, agent);
}
catch (System.Exception l_oException)
catch (System.Exception exception)
{
if (l_oException.GetIsConnectFailureException())
if (exception.GetIsConnectFailureException())
{
throw new WebConnectFailureException("Aktualisierung des Schlossstatuses wegen Netzwerkfehler fehlgeschlagen.", l_oException);
throw new WebConnectFailureException("Benachrichtigung von Start der Rückgabe wegen Netzwerkfehler fehlgeschlagen.", exception);
}
if (l_oException.GetIsForbiddenException())
if (exception.GetIsForbiddenException())
{
throw new WebForbiddenException("Aktualisierung des Schlossstatuses wegen Netzwerkfehler fehlgeschlagen.", l_oException);
throw new WebForbiddenException("Benachrichtigung von Start der Rückgabe wegen Netzwerkfehler fehlgeschlagen.", exception);
}
throw;
}
// Extract bikes from response.
return JsonConvertRethrow.DeserializeObject<ResponseContainer<ReservationBookingResponse>>(l_oBikesAvaialbeResponse)?.shareejson;
return JsonConvertRethrow.DeserializeObject<ResponseContainer<ResponseBase>>(response)?.shareejson;
#else
return null;
#endif
}
public static async Task<ReservationBookingResponse> DoUpdateLockingStateAsync(
string copriHost,
string command,
string agent = null)
{
#if !WINDOWS_UWP
string bikesAvaialbeResponse;
try
{
bikesAvaialbeResponse = await PostAsync(copriHost, command, agent);
}
catch (System.Exception exception)
{
if (exception.GetIsConnectFailureException())
{
throw new WebConnectFailureException("Aktualisierung des Schlossstatuses wegen Netzwerkfehler fehlgeschlagen.", exception);
}
if (exception.GetIsForbiddenException())
{
throw new WebForbiddenException("Aktualisierung des Schlossstatuses wegen Netzwerkfehler fehlgeschlagen.", exception);
}
throw;
}
// Extract bikes from response.
return JsonConvertRethrow.DeserializeObject<ResponseContainer<ReservationBookingResponse>>(bikesAvaialbeResponse)?.shareejson;
#else
return null;
#endif
@ -591,16 +635,16 @@ namespace TINK.Repository
{
l_oBikesAvaialbeResponse = await PostAsync(copriHost, command, agent);
}
catch (System.Exception l_oException)
catch (System.Exception exception)
{
if (l_oException.GetIsConnectFailureException())
if (exception.GetIsConnectFailureException())
{
throw new WebConnectFailureException("Buchung des Fahrrads wegen Netzwerkfehler fehlgeschlagen.", l_oException);
throw new WebConnectFailureException("Buchung des Fahrrads wegen Netzwerkfehler fehlgeschlagen.", exception);
}
if (l_oException.GetIsForbiddenException())
if (exception.GetIsForbiddenException())
{
throw new WebForbiddenException("Buchung des Fahrrads wegen Netzwerkfehler fehlgeschlagen.", l_oException);
throw new WebForbiddenException("Buchung des Fahrrads wegen Netzwerkfehler fehlgeschlagen.", exception);
}
throw;

View file

@ -1613,6 +1613,10 @@ namespace TINK.Repository
public Task<ReservationBookingResponse> CalculateAuthKeysAsync(string bikeId, Uri operatorUri) => null;
public Task<ResponseBase> StartReturningBike(
string bikeId,
Uri operatorUri) => null;
public Task<ReservationBookingResponse> UpdateLockingStateAsync(
string bikeId,
LocationDto geolocation,

View file

@ -159,6 +159,11 @@ namespace TINK.Repository
public Task<ReservationBookingResponse> CalculateAuthKeysAsync(string bikeId, Uri operatorUri)
=> throw new System.Exception("Schlosssuche im Offlinemodus nicht möglich!");
public Task<ResponseBase> StartReturningBike(
string bikeId,
Uri operatorUri)
=> throw new System.Exception("Benachrichtigung von start der Rückgabe im Offlinemodus nicht möglich!");
public Task<ReservationBookingResponse> UpdateLockingStateAsync(
string bikeId,
LocationDto geolocation,

View file

@ -1,4 +1,6 @@
namespace TINK.Repository.Exception
using TINK.MultilingualResources;
namespace TINK.Repository.Exception
{
public class WebConnectFailureException : CommunicationException
{
@ -6,13 +8,9 @@
/// Returns a hint to fix communication problem.
/// </summary>
public static string GetHintToPossibleExceptionsReasons
{
get
{
return "Ist WLAN verfügbar/ Mobilfunknetz vefügbar und mobile Daten aktiviert / ... ?";
}
}
/// <summary>
=> AppResources.ExceptionTextWebConnectFailureException;
/// <summary>
/// Constructs a communication exeption object.
/// </summary>
/// <param name="p_strMessage"></param>

View file

@ -48,6 +48,15 @@ namespace TINK.Repository
string bikeId,
Uri operatorUri);
/// <summary> Notifies COPRI about start of returning sequence. </summary>
/// <remarks> Operator specific call.</remarks>
/// <param name="bikeId">Id of the bike to return.</param>+
/// <param name="operatorUri">Holds the uri of the operator or null, in case of single operator setup.</param>
/// <returns>Response on notification about start of returning sequence.</returns>
Task<ResponseBase> StartReturningBike(
string bikeId,
Uri operatorUri);
/// <summary> Updates COPRI 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.</param>

View file

@ -55,6 +55,12 @@ namespace TINK.Repository.Request
/// <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 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>

View file

@ -96,6 +96,13 @@ namespace TINK.Repository.Request
/// <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();
public string UpateLockingState(string bikeId, LocationDto geolocation, lock_state state, double batteryPercentage)
=> throw new NotSupportedException();

View file

@ -95,15 +95,20 @@ namespace TINK.Repository.Request
public string CalculateAuthParameters(string bikeId)
=> $"request=booking_update&bike={bikeId}&authcookie={SessionCookie}{MerchantId}&genkey=1";
/// <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&bike={bikeId}&lock_state=locking&authcookie={SessionCookie}{MerchantId}";
/// <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, LocationDto geolocation, lock_state state, double batteryPercentage)
{
return $"request=booking_update&bike={bikeId}{GetLocationParameters(geolocation)}&lock_state={state}{GetBatteryPercentageParameters(batteryPercentage)}&authcookie={SessionCookie}{MerchantId}";
}
=> $"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>
/// <remarks> Operator specific call.</remarks>

View file

@ -8,6 +8,9 @@ namespace TINK.Repository.Response
{
public const string RESPONSE_OK = "OK";
/// <summary> Holds the description of the action return bike. </summary>
public const string RESPONSE_AUTHCOOKIE_EXPRIED = "Failure 1001:";
/// <summary> Holds the description of the action logout. </summary>
public const string BIKES_LOGOUT_ACTIONTEXT = "Abmeldung fehlgeschlagen.";
@ -127,6 +130,34 @@ namespace TINK.Repository.Response
return bikeInfoRequestedOccupied;
}
/// <summary> Gets if request is ok.</summary>
/// <param name="response">Response to verify.</param>
/// <param name="textOfAction">Text describing request which is shown if validation fails.</param>
/// <returns>Verified response.</returns>
public static BikesReservedOccupiedResponse GetIsResponseOk(this BikesReservedOccupiedResponse response, string textOfAction)
{
if (response == null || response.response_state == null)
{
throw new InvalidResponseException<BikesReservedOccupiedResponse>(textOfAction, null);
}
if (AuthcookieNotDefinedException.IsAuthcookieNotDefined(response, textOfAction, out AuthcookieNotDefinedException exception))
{
throw exception;
}
if (response.response_state.Trim().ToUpper().StartsWith(RESPONSE_AUTHCOOKIE_EXPRIED.ToUpper()))
{
throw new AuthcookieNotDefinedException(
$"{textOfAction}\r\n{AppResources.ExceptionTextSessionExpired}",
response);
}
GetIsResponseOk((ResponseBase)response, textOfAction);
return response;
}
/// <summary> Gets if request is ok.</summary>
/// <param name="response">Response to verify.</param>
/// <param name="textOfAction">Text describing request which is shown if validation fails.</param>