using Serilog;
using TINK.Repository.Request;
namespace TINK.ViewModel.Login
{
/// Manages the copri web view when user is logged in.
public class ManageAccountViewModel
{
/// Holds the auth cookie of the user logged in.
private string SessionCookie { get; }
/// Holds the merchant id.
private string MerchantId { get; }
///
/// Holds the current ui two letter ISO language name.
///
private string UiIsoLanguageName { get; }
/// Holds the name of the host.
private string HostName { get; }
/// Two letter ISO language name.
public ManageAccountViewModel(
string sessionCookie,
string merchantId,
string uiIsoLangugageName,
string hostName)
{
SessionCookie = sessionCookie;
MerchantId = merchantId;
UiIsoLanguageName = uiIsoLangugageName;
HostName = hostName;
}
/// Get Uri of web view managing user account.
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().Debug($"Request to open url {GetUriText()} to get privacy info.");
return GetUriText();
}
}
}
}