2021-05-13 20:03:07 +02:00
|
|
|
|
|
2022-08-30 15:42:25 +02:00
|
|
|
|
using Serilog;
|
|
|
|
|
using TINK.Repository.Request;
|
|
|
|
|
|
2021-05-13 20:03:07 +02:00
|
|
|
|
namespace TINK.ViewModel.Login
|
|
|
|
|
{
|
2022-09-06 16:08:19 +02:00
|
|
|
|
/// <summary> Manages the copri web view when user is logged in. </summary>
|
|
|
|
|
public class ManageAccountViewModel
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/// <summary> Holds the auth cookie of the user logged in.</summary>
|
|
|
|
|
private string SessionCookie { get; }
|
|
|
|
|
|
|
|
|
|
/// <summary> Holds the merchant id.</summary>
|
|
|
|
|
private string MerchantId { get; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Holds the current ui two letter ISO language name.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private string UiIsoLanguageName { get; }
|
|
|
|
|
|
|
|
|
|
/// <summary> Holds the name of the host.</summary>
|
|
|
|
|
private string HostName { get; }
|
|
|
|
|
|
|
|
|
|
/// <param name="uiIsoLangugageName">Two letter ISO language name.</param>
|
|
|
|
|
public ManageAccountViewModel(
|
|
|
|
|
string sessionCookie,
|
|
|
|
|
string merchantId,
|
|
|
|
|
string uiIsoLangugageName,
|
|
|
|
|
string hostName)
|
|
|
|
|
{
|
|
|
|
|
SessionCookie = sessionCookie;
|
|
|
|
|
MerchantId = merchantId;
|
|
|
|
|
UiIsoLanguageName = uiIsoLangugageName;
|
|
|
|
|
HostName = hostName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary> Get Uri of web view managing user account. </summary>
|
|
|
|
|
public string Uri
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
var sessionIdQueryElement = QueryBuilderHelper.GetSessionIdQueryElement("?", MerchantId, SessionCookie);
|
|
|
|
|
|
|
|
|
|
string GetUriText()
|
|
|
|
|
=> !string.IsNullOrEmpty(sessionIdQueryElement)
|
|
|
|
|
? $"https://{HostName}{sessionIdQueryElement}{QueryBuilderHelper.GetLanguageQueryElement("&", UiIsoLanguageName)}"
|
|
|
|
|
: $"https://{HostName}";
|
|
|
|
|
|
|
|
|
|
Log.ForContext<ManageAccountViewModel>().Debug($"Request to open url {GetUriText()} to get privacy info.");
|
|
|
|
|
|
|
|
|
|
return GetUriText();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-05-13 20:03:07 +02:00
|
|
|
|
}
|