2023-02-22 14:03:35 +01:00
using System ;
using TINK.Model.Device ;
2022-01-04 18:54:03 +01:00
using TINK.Repository ;
2021-05-13 20:03:07 +02:00
namespace TINK.Model.Connector
{
2022-09-06 16:08:19 +02:00
public class ConnectorFactory
{
/// <summary>
/// Gets a connector object depending on whether beein onlin or offline.
/// </summary>
2023-02-22 14:03:35 +01:00
/// <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>
2022-09-06 16:08:19 +02:00
/// <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>
2023-02-22 14:03:35 +01:00
/// <param name="smartDevice">Holds info about smart device.</param>
2022-09-06 16:08:19 +02:00
public static IConnector Create (
bool isConnected ,
Uri activeUri ,
AppContextInfo appContextInfo ,
string uiIsoLangugageName ,
string sessionCookie ,
string mail ,
2023-02-22 14:03:35 +01:00
ISmartDevice smartDevice = null ,
2022-09-06 16:08:19 +02:00
TimeSpan ? expiresAfter = null )
{
return isConnected
2023-02-22 14:03:35 +01:00
? new Connector ( activeUri , appContextInfo , uiIsoLangugageName , sessionCookie , mail , smartDevice , expiresAfter : expiresAfter ) as IConnector
: new ConnectorCache ( appContextInfo , uiIsoLangugageName , sessionCookie , mail , smartDevice ) ;
2022-09-06 16:08:19 +02:00
}
}
2021-05-13 20:03:07 +02:00
}