You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.2 KiB
C#
47 lines
1.2 KiB
C#
using System.Security;
|
|
using DS.Module.Core;
|
|
using DS.Module.Core.Extensions;
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
namespace DS.WMS.Core.Invoice.Method
|
|
{
|
|
/// <summary>
|
|
/// 提供对HTTP请求的低级别访问
|
|
/// </summary>
|
|
internal sealed class InvoiceApiFox : ApiFox
|
|
{
|
|
/// <summary>
|
|
/// 用户Key
|
|
/// </summary>
|
|
public string? UserKey { get; set; }
|
|
|
|
/// <summary>
|
|
/// 用户密钥
|
|
/// </summary>
|
|
public SecureString? UserSecret { get; private set; }
|
|
|
|
|
|
public InvoiceApiFox(IConfiguration config)
|
|
{
|
|
BaseUri = new Uri(config.GetValue<string>("InvoiceApi:BaseUrl"));
|
|
UserKey = config.GetValue<string>("InvoiceApi:UserKey");
|
|
|
|
string? us = config.GetValue<string>("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());
|
|
}
|
|
|
|
|
|
}
|
|
}
|