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

@ -286,7 +286,7 @@ namespace TINK.Model.Connector
}
DoReturnResponse response
= (await CopriServer.DoReturn(bike.Id, location, smartDevice, bike.OperatorUri)).GetIsReturnBikeResponseOk(bike.Id);
= (await CopriServer.DoReturn(bike.Id, location, bike.OperatorUri)).GetIsReturnBikeResponseOk(bike.Id);
bike.Load(Bikes.BikeInfoNS.BC.NotifyPropertyChangedLevel.None);
return response?.Create() ?? new BookingFinishedModel();

View file

@ -1,4 +1,5 @@
using System;
using System;
using TINK.Model.Device;
using TINK.Model.Services.CopriApi;
using TINK.Repository;
@ -9,12 +10,13 @@ namespace TINK.Model.Connector
/// </summary>
public class Connector : IConnector
{
/// <summary>Constructs a copri connector object.</summary>
/// <summary>Constructs a copri connector object to connect to copri by https with cache fallback.</summary>
/// <param name="activeUri"> Uri to connect to.</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="sessionCookie"> Holds the session cookie.</param>
/// <param name="mail">Mail of user.</param>
/// <param name="smartDevice">Holds info about smart device.</param>
/// <param name="expiresAfter">Timespan which holds value after which cache expires.</param>
/// <param name="server"> Is null in production and migh be a mock in testing context.</param>
public Connector(
@ -23,25 +25,28 @@ namespace TINK.Model.Connector
string uiIsoLangugageName,
string sessionCookie,
string mail,
ISmartDevice smartDevice = null,
TimeSpan? expiresAfter = null,
ICachedCopriServer server = null)
{
Command = GetCommand(
Command = CreateCommand(
server ?? new CopriProviderHttps(
activeUri,
appContextInfo.MerchantId,
appContextInfo,
uiIsoLangugageName,
smartDevice,
sessionCookie),
sessionCookie,
mail);
Query = GetQuery(
Query = CreateQuery(
server ?? new CopriProviderHttps(
activeUri,
appContextInfo.MerchantId,
appContextInfo,
uiIsoLangugageName,
smartDevice,
sessionCookie,
expiresAfter),
sessionCookie,
@ -57,13 +62,13 @@ namespace TINK.Model.Connector
/// <summary> True if connector has access to copri server, false if cached values are used. </summary>
public bool IsConnected => Command.IsConnected;
/// <summary> Gets a command object to perform copri commands. </summary>
public static ICommand GetCommand(ICopriServerBase copri, string sessioncookie, string mail) => string.IsNullOrEmpty(sessioncookie)
/// <summary> Creates a command object to perform copri commands. </summary>
public static ICommand CreateCommand(ICopriServerBase copri, string sessioncookie, string mail) => string.IsNullOrEmpty(sessioncookie)
? new Command(copri)
: new CommandLoggedIn(copri, sessioncookie, mail, () => DateTime.Now) as ICommand;
/// <summary> Gets a command object to perform copri queries. </summary>
private static IQuery GetQuery(ICachedCopriServer copri, string sessioncookie, string mail) => string.IsNullOrEmpty(sessioncookie)
/// <summary> Creates a command object to perform copri queries. </summary>
private static IQuery CreateQuery(ICachedCopriServer copri, string sessioncookie, string mail) => string.IsNullOrEmpty(sessioncookie)
? new CachedQuery(copri) as IQuery
: new CachedQueryLoggedIn(copri, sessioncookie, mail, () => DateTime.Now);
}

View file

@ -1,4 +1,5 @@
using System;
using System;
using TINK.Model.Device;
using TINK.Model.Services.CopriApi;
using TINK.Repository;
@ -9,26 +10,28 @@ namespace TINK.Model.Connector
/// </summary>
public class ConnectorCache : IConnector
{
/// <summary>Constructs a copri connector object.</summary>
/// <summary>Constructs a copri connector object to connect to cache.</summary>
/// <remarks>Used for offline szenario to ensure responsiveness of app by preventing hopeless tries to communicate with COPRI. </remarks>
/// <param name="uiIsoLangugageName">Two letter ISO language name.</param>
/// <param name="sessionCookie"> Holds the session cookie.</param>
/// <param name="mail">Mail of user.</param>
/// <param name="smartDevice">Holds info about smart device.</param>
/// <param name="server"> Is null in production and migh be a mock in testing context.</param>
public ConnectorCache(
AppContextInfo appContextInfo,
string uiIsoLangugageName,
string sessionCookie,
string mail,
ISmartDevice smartDevice = null,
ICopriServer server = null)
{
Command = Connector.GetCommand(
server ?? new CopriProviderMonkeyStore(appContextInfo.MerchantId, uiIsoLangugageName, sessionCookie),
Command = Connector.CreateCommand(
server ?? new CopriProviderMonkeyStore(appContextInfo.MerchantId, uiIsoLangugageName, sessionCookie, smartDevice),
sessionCookie,
mail);
Query = GetQuery(
server ?? new CopriProviderMonkeyStore(appContextInfo.MerchantId, uiIsoLangugageName, sessionCookie),
server ?? new CopriProviderMonkeyStore(appContextInfo.MerchantId, uiIsoLangugageName, sessionCookie, smartDevice),
sessionCookie,
mail);
}

View file

@ -1,4 +1,5 @@
using System;
using System;
using TINK.Model.Device;
using TINK.Repository;
namespace TINK.Model.Connector
@ -8,10 +9,13 @@ namespace TINK.Model.Connector
/// <summary>
/// Gets a connector object depending on whether beein onlin or offline.
/// </summary>
/// <param name="isConnected">True if online, false if offline. If offline cache connector is returned.</param>
/// <param name="isConnected">
/// True if online, false if offline.
/// If offline cache connector is returned to avoid performance penalty which would happen when trying to communicate with backend in offline scenario.
/// </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>
/// <returns></returns>
/// <param name="smartDevice">Holds info about smart device.</param>
public static IConnector Create(
bool isConnected,
Uri activeUri,
@ -19,11 +23,12 @@ namespace TINK.Model.Connector
string uiIsoLangugageName,
string sessionCookie,
string mail,
ISmartDevice smartDevice = null,
TimeSpan? expiresAfter = null)
{
return isConnected
? new Connector(activeUri, appContextInfo, uiIsoLangugageName, sessionCookie, mail, expiresAfter: expiresAfter) as IConnector
: new ConnectorCache(appContextInfo, uiIsoLangugageName, sessionCookie, mail);
? new Connector(activeUri, appContextInfo, uiIsoLangugageName, sessionCookie, mail, smartDevice, expiresAfter: expiresAfter) as IConnector
: new ConnectorCache(appContextInfo, uiIsoLangugageName, sessionCookie, mail, smartDevice);
}
}
}