using System.Security;
using DS.Module.Core;
using DS.Module.Core.Extensions;
using Microsoft.Extensions.Configuration;
namespace DS.WMS.Core.Invoice.Method
{
///
/// 提供对HTTP请求的低级别访问
///
internal sealed class InvoiceApiFox : ApiFox
{
///
/// 用户Key
///
public string? UserKey { get; set; }
///
/// 用户密钥
///
public SecureString? UserSecret { get; private set; }
public InvoiceApiFox(IConfiguration config)
{
BaseUri = new Uri(config.GetValue("InvoiceApi:BaseUrl"));
UserKey = config.GetValue("InvoiceApi:UserKey");
var us = config.GetValue("InvoiceApi:UserSecret");
if (!us.IsNullOrEmpty())
{
UserSecret = new SecureString();
for (int i = 0; i < us.Length; i++)
UserSecret.AppendChar(us[i]);
UserSecret.MakeReadOnly();
}
us = null;
DefaultHeaders.Add("USER_KEY", UserKey ?? string.Empty);
DefaultHeaders.Add("USER_SECRET", UserSecret?.ToString());
}
}
}