feat(SmsParams): Aktualisiert, um IHttpClientOptions zu implementieren
This commit is contained in:
parent
6e6f3fd2ed
commit
ed80839777
@ -8,49 +8,12 @@ namespace EnvelopeGenerator.Application.Configurations.GtxMessaging
|
|||||||
public class SmsParams : IHttpClientOptions
|
public class SmsParams : IHttpClientOptions
|
||||||
{
|
{
|
||||||
//TODO: Add a regex check to init methods to reduce the chance of errors.
|
//TODO: Add a regex check to init methods to reduce the chance of errors.
|
||||||
public string Uri { get; set; } = "https://rest.gtx-messaging.net";
|
public required string Uri { get; init; }
|
||||||
|
|
||||||
public string Path { get; set; } = "smsc/sendsms";
|
public string? Path { get; init; }
|
||||||
|
|
||||||
// path params
|
public IEnumerable<KeyValuePair<string, object>>? Headers { get; init; }
|
||||||
public required string AuthKey { get; init; }
|
|
||||||
|
|
||||||
public string? Format { get; init; }
|
public IEnumerable<KeyValuePair<string, object?>>? QueryParams { get; init; }
|
||||||
|
|
||||||
// header params
|
|
||||||
public string? Accept { get; init; }
|
|
||||||
|
|
||||||
public string? ContentType { get; init; }
|
|
||||||
|
|
||||||
// query params
|
|
||||||
public required string From { get; init; }
|
|
||||||
|
|
||||||
public required Dictionary<string, string> Texts { get; init; }
|
|
||||||
|
|
||||||
public int? DlrMask { get; init; }
|
|
||||||
|
|
||||||
public string? DlrUrl { get; init; }
|
|
||||||
|
|
||||||
public string? Udh { get; init; }
|
|
||||||
|
|
||||||
public int? Dcs { get; init; }
|
|
||||||
|
|
||||||
public int? MClass { get; init; }
|
|
||||||
|
|
||||||
public int? MWI { get; init; }
|
|
||||||
|
|
||||||
public int? Coding { get; init; }
|
|
||||||
|
|
||||||
public string? Charset { get; init; }
|
|
||||||
|
|
||||||
public int? Validity { get; init; }
|
|
||||||
|
|
||||||
public DateTime? ValidityTime { get; init; }
|
|
||||||
|
|
||||||
public int? Deferred { get; init; }
|
|
||||||
|
|
||||||
public DateTime? DeferredTime { get; init; }
|
|
||||||
|
|
||||||
internal string AuthPath => Format is null ? AuthKey : string.Join('/', AuthKey, Format);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="AutoMapper" Version="13.0.1" />
|
<PackageReference Include="AutoMapper" Version="13.0.1" />
|
||||||
<PackageReference Include="DigitalData.Core.Abstractions" Version="2.1.0" />
|
<PackageReference Include="DigitalData.Core.Abstractions" Version="2.2.0" />
|
||||||
<PackageReference Include="DigitalData.Core.Application" Version="2.0.0" />
|
<PackageReference Include="DigitalData.Core.Application" Version="2.0.0" />
|
||||||
<PackageReference Include="DigitalData.Core.Client" Version="1.1.0" />
|
<PackageReference Include="DigitalData.Core.Client" Version="1.1.0" />
|
||||||
<PackageReference Include="DigitalData.Core.DTO" Version="2.0.0" />
|
<PackageReference Include="DigitalData.Core.DTO" Version="2.0.0" />
|
||||||
|
|||||||
@ -1,29 +1,20 @@
|
|||||||
using DigitalData.Core.Abstractions.Client;
|
using DigitalData.Core.Abstractions.Client;
|
||||||
using DigitalData.Core.DTO;
|
|
||||||
using EnvelopeGenerator.Application.Configurations.GtxMessaging;
|
using EnvelopeGenerator.Application.Configurations.GtxMessaging;
|
||||||
using Microsoft.Extensions.Options;
|
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Application.Services
|
namespace EnvelopeGenerator.Application.Services
|
||||||
{
|
{
|
||||||
public class GtxMessagingService
|
public class GtxMessagingService
|
||||||
{
|
{
|
||||||
private readonly SmsParams _smsParams;
|
|
||||||
|
|
||||||
private readonly IHttpClientService<SmsParams> _smsClient;
|
private readonly IHttpClientService<SmsParams> _smsClient;
|
||||||
|
|
||||||
private readonly string _authPath;
|
public GtxMessagingService(IHttpClientService<SmsParams> smsClient)
|
||||||
|
|
||||||
public GtxMessagingService(IOptions<SmsParams> smsParamsOptions, IHttpClientService<SmsParams> smsClient)
|
|
||||||
{
|
{
|
||||||
_smsParams = smsParamsOptions.Value;
|
|
||||||
_smsClient = smsClient;
|
_smsClient = smsClient;
|
||||||
|
|
||||||
_authPath = _smsParams.AuthPath;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task SendSms()
|
public async Task SendSms()
|
||||||
{
|
{
|
||||||
await _smsClient.FetchAsync(path: _authPath);
|
await _smsClient.FetchAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user