69 lines
3.7 KiB
C#
69 lines
3.7 KiB
C#
using System;
|
|
using System.Configuration;
|
|
using System.IO;
|
|
|
|
namespace LCU.API.Internal.CoreSoapApiWrapper.Models
|
|
{
|
|
public class SoapConfiguration
|
|
{
|
|
public SoapConfiguration()
|
|
{
|
|
int defaultValue;
|
|
|
|
SafUrl = ConfigurationManager.AppSettings["soapconnection:safUrl"];
|
|
DeviceId = ConfigurationManager.AppSettings["soapconnection:deviceId"];
|
|
UserId = ReadSecret("/vault/secrets/core-soap-api-wrapper-soap-connection-user-id.json") ?? ConfigurationManager.AppSettings["soapconnection:userId"];
|
|
Password = ReadSecret("/vault/secrets/core-soap-api-wrapper-soap-connection-password.json") ?? ConfigurationManager.AppSettings["soapconnection:password"];
|
|
EnvironmentCode = ConfigurationManager.AppSettings["soapconnection:prodEnvCd"];
|
|
DefCode = ConfigurationManager.AppSettings["soapconnection:prodDefCd"];
|
|
ApplicationId = ConfigurationManager.AppSettings["soapconnection:applId"];
|
|
Endpoint = ConfigurationManager.AppSettings["soapconnection:endpoint"];
|
|
ApprovalPersonNumber = ConfigurationManager.AppSettings["soapconnection:approvalpersonnumber"];
|
|
OverrideCashBoxNumber = ConfigurationManager.AppSettings["soapconnection:overridecashboxnumber"];
|
|
SocketDeviceId = ConfigurationManager.AppSettings["socketconnection:deviceId"];
|
|
SocketApplicationId = ConfigurationManager.AppSettings["socketconnection:applId"];
|
|
SocketUserId = ReadSecret("/vault/secrets/core-soap-api-wrapper-socket-connection-user-id.json") ?? ConfigurationManager.AppSettings["socketconnection:userId"];
|
|
SocketPassword = ReadSecret("/vault/secrets/core-soap-api-wrapper-socket-connection-password.json") ?? ConfigurationManager.AppSettings["socketconnection:password"];
|
|
SocketTimeout = int.TryParse(ConfigurationManager.AppSettings["socketconnection:timeout"], out defaultValue) ? defaultValue : 10000;
|
|
IPAddress = ConfigurationManager.AppSettings["socketconnection:ipAddress"];
|
|
PortId = int.TryParse(ConfigurationManager.AppSettings["socketconnection:portId"], out defaultValue) ? defaultValue : 2503;
|
|
RequestType = ConfigurationManager.AppSettings["socketconnection:reqType"];
|
|
AuthenticationType = ConfigurationManager.AppSettings["socketconnection:authType"];
|
|
|
|
string ReadSecret(string path)
|
|
{
|
|
try
|
|
{
|
|
var s = File.ReadAllText(path).Trim();
|
|
if (string.IsNullOrWhiteSpace(s))
|
|
throw new InvalidOperationException($"Secret file '{path}' is empty.");
|
|
return s;
|
|
}
|
|
catch (Exception)
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
|
|
public string SafUrl { get; set; }
|
|
public string DeviceId { get; set; }
|
|
public string UserId { get; set; }
|
|
public string Password { get; set; }
|
|
public string EnvironmentCode { get; set; }
|
|
public string DefCode { get; set; }
|
|
public string ApplicationId { get; set; }
|
|
public string Endpoint { get; set; }
|
|
public string ApprovalPersonNumber { get; set; }
|
|
public string OverrideCashBoxNumber { get; set; }
|
|
public string SocketDeviceId { get; set; }
|
|
public string SocketApplicationId { get; set; }
|
|
public string SocketUserId { get; set; }
|
|
public string SocketPassword { get; set; }
|
|
public int SocketTimeout { get; set; }
|
|
public string IPAddress { get; set; }
|
|
public int PortId { get; set; }
|
|
public string RequestType { get; set; }
|
|
public string AuthenticationType { get; set; }
|
|
}
|
|
} |