Version 3.0.360

This commit is contained in:
Anja 2023-02-22 14:03:35 +01:00
parent 5c0b2e70c9
commit faf68061f4
160 changed files with 2114 additions and 1932 deletions

View file

@ -12,7 +12,7 @@ using TINK.Repository.Response;
namespace TINK.Model.Services.CopriApi
{
/// <summary> Object which manages calls to copri in a thread safe way inclding cache functionality. </summary>
/// <summary> Object which manages calls to copri in a thread safe way including cache functionality. </summary>
public class CopriProviderHttps : ICachedCopriServer
{
/// <summary> Object which manages stored copri answers. </summary>
@ -34,6 +34,7 @@ namespace TINK.Model.Services.CopriApi
/// <param name="copriHost"></param>
/// <param name="appContextInfo">Provides app related info (app name and version, merchantid) to pass to COPRI.</param>
/// <param name="uiIsoLangugageName">Two letter ISO language name.</param>
/// <param name="smartDevice">Holds info about smart device.</param>
/// <param name="sessionCookie">Cookie of user if a user is logged in, false otherwise.</param>
/// <param name="expiresAfter">Timespan which holds value after which cache expires.</param>
public CopriProviderHttps(
@ -41,13 +42,14 @@ namespace TINK.Model.Services.CopriApi
string merchantId,
AppContextInfo appContextInfo,
string uiIsoLangugageName,
ISmartDevice smartDevice = null,
string sessionCookie = null,
TimeSpan? expiresAfter = null,
ICopriCache cacheServer = null,
ICopriServer httpsServer = null)
{
CacheServer = cacheServer ?? new CopriCallsMonkeyStore(merchantId, uiIsoLangugageName, sessionCookie, expiresAfter);
HttpsServer = httpsServer ?? new CopriCallsHttps(copriHost, appContextInfo, uiIsoLangugageName, sessionCookie);
CacheServer = cacheServer ?? new CopriCallsMonkeyStore(merchantId, uiIsoLangugageName, sessionCookie, smartDevice, expiresAfter);
HttpsServer = httpsServer ?? new CopriCallsHttps(copriHost, appContextInfo, uiIsoLangugageName, sessionCookie, smartDevice);
}
/// <summary>Gets bikes available.</summary>
@ -275,20 +277,17 @@ namespace TINK.Model.Services.CopriApi
public async Task<DoReturnResponse> DoReturn(
string bikeId,
LocationDto location,
ISmartDevice smartDevice,
Uri operatorUri)
=> await HttpsServer.DoReturn(bikeId, location, smartDevice, operatorUri);
=> await HttpsServer.DoReturn(bikeId, location, operatorUri);
/// <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>
/// <param name="operatorUri">Holds the uri of the operator or null, in case of single operator setup.</param>
/// <returns>Response on returning request.</returns>
public async Task<DoReturnResponse> ReturnAndStartClosingAsync(
string bikeId,
ISmartDevice smartDevice,
Uri operatorUri)
=> await HttpsServer.ReturnAndStartClosingAsync(bikeId, smartDevice, operatorUri);
=> await HttpsServer.ReturnAndStartClosingAsync(bikeId, operatorUri);
/// <summary>
/// Submits feedback to copri server.

View file

@ -11,6 +11,7 @@ using TINK.Services.CopriApi.Exception;
namespace TINK.Model.Services.CopriApi
{
/// <summary> Object which manages calls to cache. </summary>
public class CopriProviderMonkeyStore : ICopriServer
{
/// <summary> Object which manages stored copri answers. </summary>
@ -25,12 +26,14 @@ namespace TINK.Model.Services.CopriApi
/// <summary> Constructs object which Object which manages stored copri answers in a thread save way. </summary>
/// <param name="merchantId">Id of the merchant TINK-App.</param>
/// <param name="uiIsoLangugageName">Two letter ISO language name.</param>
/// <param name="smartDevice">Holds info about smart device.</param>
public CopriProviderMonkeyStore(
string merchantId,
string uiIsoLangugageName,
string sessionCookie)
string sessionCookie,
ISmartDevice smartDevice = null)
{
monkeyStore = new CopriCallsMonkeyStore(merchantId, uiIsoLangugageName, sessionCookie);
monkeyStore = new CopriCallsMonkeyStore(merchantId, uiIsoLangugageName, sessionCookie, smartDevice);
}
/// <summary> Gets the merchant id.</summary>
@ -82,15 +85,13 @@ namespace TINK.Model.Services.CopriApi
public async Task<DoReturnResponse> DoReturn(
string bikeId,
LocationDto geolocation,
ISmartDevice smartDevice,
Uri operatorUri)
=> await monkeyStore.DoReturn(bikeId, geolocation, smartDevice, operatorUri);
=> await monkeyStore.DoReturn(bikeId, geolocation, operatorUri);
public async Task<DoReturnResponse> ReturnAndStartClosingAsync(
string bikeId,
ISmartDevice smartDevice,
Uri operatorUri)
=> await monkeyStore.ReturnAndStartClosingAsync(bikeId, smartDevice, operatorUri);
=> await monkeyStore.ReturnAndStartClosingAsync(bikeId, operatorUri);
public Task<SubmitFeedbackResponse> DoSubmitFeedback(string bikeId, int? currentChargeBars, string messge, bool bIsBikeBroke, Uri operatorUri)
=> throw new RequestNotCachableException(nameof(DoSubmitFeedback));

View file

@ -1,4 +1,4 @@
using System;
using System;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
@ -20,18 +20,28 @@ namespace TINK.Services.CopriApi
/// <summary> Timeout for open/ close operations.</summary>
private const int OPEN_CLOSE_TIMEOUT_MS = 50000;
/// <summary> Opens lock.</summary>
/// <param name="copriServer"> Instance to communicate with backend.</param>
/// <param name="bike">Bike object holding id of bike to open. Lock state of object is updated after open request.</param>
public static async Task OpenAync(
this ICopriServerBase copriServer,
IBikeInfoMutable bike)
{
if (!(copriServer is ICachedCopriServer cachedServer))
throw new ArgumentNullException(nameof(copriServer));
await cachedServer.OpenAync(bike);
}
/// <summary> Opens lock.</summary>
/// <param name="corpiServer"> Instance to communicate with backend.</param>
/// <param name="bike">Bike object holding id of bike to open. Lock state of object is updated after open request.</param>
public static async Task OpenAync(
this ICopriServerBase corpiServer,
this ICachedCopriServer cachedServer,
IBikeInfoMutable bike)
{
if (!(corpiServer is ICachedCopriServer cachedServer))
throw new ArgumentNullException(nameof(corpiServer));
// Send command to close lock
await corpiServer.UpdateLockingStateAsync(
await cachedServer.UpdateLockingStateAsync(
bike.Id,
Repository.Request.lock_state.unlocking,
bike.OperatorUri);
@ -169,7 +179,7 @@ namespace TINK.Services.CopriApi
// Send command to open lock
DoReturnResponse response =
await corpiServer.ReturnAndStartClosingAsync(bike.Id, smartDevice, bike.OperatorUri);
await corpiServer.ReturnAndStartClosingAsync(bike.Id, bike.OperatorUri);
// Upate booking state
bike.Load(Model.Bikes.BikeInfoNS.BC.NotifyPropertyChangedLevel.None);