Compare commits
4 Commits
5da306acd3
...
4a62ab0c56
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4a62ab0c56 | ||
|
|
132acd35cc | ||
|
|
ed80839777 | ||
|
|
6e6f3fd2ed |
@@ -7,50 +7,16 @@ namespace EnvelopeGenerator.Application.Configurations.GtxMessaging
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class SmsParams : IHttpClientOptions
|
public class SmsParams : IHttpClientOptions
|
||||||
{
|
{
|
||||||
//TODO: Add a regex check to init methods to reduce the chance of errors.
|
public required string Uri { get; init; }
|
||||||
public string Uri { get; set; } = "https://rest.gtx-messaging.net";
|
|
||||||
|
|
||||||
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 RecipientQueryParamName { get; init; } = "from";
|
||||||
public string? Accept { get; init; }
|
|
||||||
|
|
||||||
public string? ContentType { get; init; }
|
public string MessageQueryParamName { get; init; } = "text";
|
||||||
|
|
||||||
// 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,5 +1,4 @@
|
|||||||
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;
|
using Microsoft.Extensions.Options;
|
||||||
|
|
||||||
@@ -7,23 +6,22 @@ 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;
|
private readonly SmsParams _smsParams;
|
||||||
|
|
||||||
public GtxMessagingService(IOptions<SmsParams> smsParamsOptions, IHttpClientService<SmsParams> smsClient)
|
public GtxMessagingService(IHttpClientService<SmsParams> smsClient, IOptions<SmsParams> smsParamsOptions)
|
||||||
{
|
{
|
||||||
_smsParams = smsParamsOptions.Value;
|
|
||||||
_smsClient = smsClient;
|
_smsClient = smsClient;
|
||||||
|
_smsParams = smsParamsOptions.Value;
|
||||||
_authPath = _smsParams.AuthPath;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task SendSms()
|
public async Task SendSmsAsync(string recipient, string message)
|
||||||
{
|
{
|
||||||
await _smsClient.FetchAsync(path: _authPath);
|
await _smsClient.FetchAsync(queryParams: new Dictionary<string, object?>() {
|
||||||
|
{ _smsParams.RecipientQueryParamName, recipient },
|
||||||
|
{ _smsParams.MessageQueryParamName, message }
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="DigitalData.Core.Abstractions" Version="2.1.0" />
|
<PackageReference Include="DigitalData.Core.Abstractions" Version="2.2.0" />
|
||||||
<PackageReference Include="DigitalData.Core.API" Version="2.0.0" />
|
<PackageReference Include="DigitalData.Core.API" Version="2.0.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.15" />
|
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.15" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="DigitalData.Core.Abstractions" Version="2.1.0" />
|
<PackageReference Include="DigitalData.Core.Abstractions" Version="2.2.0" />
|
||||||
<PackageReference Include="DigitalData.Core.Infrastructure" Version="2.0.0" />
|
<PackageReference Include="DigitalData.Core.Infrastructure" Version="2.0.0" />
|
||||||
<PackageReference Include="DigitalData.EmailProfilerDispatcher" Version="2.0.0" />
|
<PackageReference Include="DigitalData.EmailProfilerDispatcher" Version="2.0.0" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.16" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.16" />
|
||||||
|
|||||||
@@ -46,7 +46,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="AutoMapper" Version="13.0.1" />
|
<PackageReference Include="AutoMapper" Version="13.0.1" />
|
||||||
<PackageReference Include="BuildBundlerMinifier2022" Version="2.9.9" />
|
<PackageReference Include="BuildBundlerMinifier2022" Version="2.9.9" />
|
||||||
<PackageReference Include="DigitalData.Core.Abstractions" Version="2.1.0" />
|
<PackageReference Include="DigitalData.Core.Abstractions" Version="2.2.0" />
|
||||||
<PackageReference Include="DigitalData.Core.API" Version="2.0.0" />
|
<PackageReference Include="DigitalData.Core.API" Version="2.0.0" />
|
||||||
<PackageReference Include="DigitalData.EmailProfilerDispatcher" Version="2.0.0" />
|
<PackageReference Include="DigitalData.EmailProfilerDispatcher" Version="2.0.0" />
|
||||||
<PackageReference Include="HtmlSanitizer" Version="8.0.865" />
|
<PackageReference Include="HtmlSanitizer" Version="8.0.865" />
|
||||||
|
|||||||
Reference in New Issue
Block a user