Reorganized namespaces
All checks were successful
Branch Build / build-test-deploy (push) Successful in 1m19s
All checks were successful
Branch Build / build-test-deploy (push) Successful in 1m19s
This commit is contained in:
@@ -14,6 +14,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- Channel implementations (SMS, WhatsApp, ...) are extensions to the `ILinkMobilityClient` interface.
|
- Channel implementations (SMS, WhatsApp, ...) are extensions to the `ILinkMobilityClient` interface.
|
||||||
|
- Reorganized namespaces to reflect parts of the API
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
|
||||||
|
- `IQueryParameter` as no usage on API docs found (for now)
|
||||||
|
|
||||||
|
|
||||||
## [v0.1.1] - 2026-03-13
|
## [v0.1.1] - 2026-03-13
|
||||||
|
|||||||
@@ -10,11 +10,11 @@ So I decided to implement the current available API myself with a more modern (a
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
Published under [MIT License] (see [**tl;dr**Legal])
|
Published under [MIT License] (see [choose a license])
|
||||||
|
|
||||||
|
|
||||||
[LINK Mobility REST API]: https://developer.linkmobility.eu/
|
[LINK Mobility REST API]: https://developer.linkmobility.eu/
|
||||||
[outdated repository]: https://github.com/websms-com/websmscom-csharp
|
[outdated repository]: https://github.com/websms-com/websmscom-csharp
|
||||||
[.NET Standard 2.0]: https://learn.microsoft.com/en-us/dotnet/standard/net-standard?tabs=net-standard-2-0
|
[.NET Standard 2.0]: https://learn.microsoft.com/en-us/dotnet/standard/net-standard?tabs=net-standard-2-0
|
||||||
[MIT License]: LICENSE.txt
|
[MIT License]: LICENSE.txt
|
||||||
[**tl;dr**Legal]: https://www.tldrlegal.com/license/mit-license
|
[choose a license]: https://choosealicense.com/licenses/mit/
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
namespace AMWD.Net.Api.LinkMobility
|
namespace AMWD.Net.Api.LinkMobility
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Custom status codes as defined by <see href="https://developer.linkmobility.eu/sms-api/rest-api#section/Status-codes">Link Mobility</see>.
|
/// Custom status codes as defined by
|
||||||
|
/// <see href="https://developer.linkmobility.eu/sms-api/rest-api#section/Status-codes">LINK Mobility</see>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public enum StatusCodes : int
|
public enum StatusCodes : int
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -15,8 +15,7 @@ namespace AMWD.Net.Api.LinkMobility
|
|||||||
/// <typeparam name="TRequest">The type of the request.</typeparam>
|
/// <typeparam name="TRequest">The type of the request.</typeparam>
|
||||||
/// <param name="requestPath">The path of the API endpoint.</param>
|
/// <param name="requestPath">The path of the API endpoint.</param>
|
||||||
/// <param name="request">The request data.</param>
|
/// <param name="request">The request data.</param>
|
||||||
/// <param name="queryParams">Optional query parameters.</param>
|
|
||||||
/// <param name="cancellationToken">A cancellation token to propagate notification that operations should be canceled.</param>
|
/// <param name="cancellationToken">A cancellation token to propagate notification that operations should be canceled.</param>
|
||||||
Task<TResponse> PostAsync<TResponse, TRequest>(string requestPath, TRequest? request, IQueryParameter? queryParams = null, CancellationToken cancellationToken = default);
|
Task<TResponse> PostAsync<TResponse, TRequest>(string requestPath, TRequest? request, CancellationToken cancellationToken = default);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ using System.Security.Authentication;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using AMWD.Net.Api.LinkMobility.Utils;
|
||||||
|
|
||||||
namespace AMWD.Net.Api.LinkMobility
|
namespace AMWD.Net.Api.LinkMobility
|
||||||
{
|
{
|
||||||
@@ -79,12 +80,12 @@ namespace AMWD.Net.Api.LinkMobility
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public async Task<TResponse> PostAsync<TResponse, TRequest>(string requestPath, TRequest? request, IQueryParameter? queryParams = null, CancellationToken cancellationToken = default)
|
public async Task<TResponse> PostAsync<TResponse, TRequest>(string requestPath, TRequest? request, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
ThrowIfDisposed();
|
ThrowIfDisposed();
|
||||||
ValidateRequestPath(requestPath);
|
ValidateRequestPath(requestPath);
|
||||||
|
|
||||||
string requestUrl = BuildRequestUrl(requestPath, queryParams);
|
string requestUrl = BuildRequestUrl(requestPath);
|
||||||
var httpContent = ConvertRequest(request);
|
var httpContent = ConvertRequest(request);
|
||||||
|
|
||||||
var httpRequest = new HttpRequestMessage
|
var httpRequest = new HttpRequestMessage
|
||||||
@@ -99,7 +100,7 @@ namespace AMWD.Net.Api.LinkMobility
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
private string BuildRequestUrl(string requestPath, IQueryParameter? queryParams = null)
|
private string BuildRequestUrl(string requestPath)
|
||||||
{
|
{
|
||||||
string path = requestPath.Trim().TrimStart('/');
|
string path = requestPath.Trim().TrimStart('/');
|
||||||
var param = new Dictionary<string, string>();
|
var param = new Dictionary<string, string>();
|
||||||
@@ -110,13 +111,6 @@ namespace AMWD.Net.Api.LinkMobility
|
|||||||
param[kvp.Key] = kvp.Value;
|
param[kvp.Key] = kvp.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
var customQueryParams = queryParams?.GetQueryParameters();
|
|
||||||
if (customQueryParams?.Count > 0)
|
|
||||||
{
|
|
||||||
foreach (var kvp in customQueryParams)
|
|
||||||
param[kvp.Key] = kvp.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (param.Count == 0)
|
if (param.Count == 0)
|
||||||
return path;
|
return path;
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
namespace AMWD.Net.Api.LinkMobility
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Represents options defined via query parameters.
|
|
||||||
/// </summary>
|
|
||||||
public interface IQueryParameter
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Retrieves the query parameters.
|
|
||||||
/// </summary>
|
|
||||||
IReadOnlyDictionary<string, string> GetQueryParameters();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
using Newtonsoft.Json.Converters;
|
using Newtonsoft.Json.Converters;
|
||||||
|
|
||||||
namespace AMWD.Net.Api.LinkMobility
|
namespace AMWD.Net.Api.LinkMobility.Text
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Specifies the type of sender address.
|
/// Specifies the type of sender address.
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
using Newtonsoft.Json.Converters;
|
using Newtonsoft.Json.Converters;
|
||||||
|
|
||||||
namespace AMWD.Net.Api.LinkMobility
|
namespace AMWD.Net.Api.LinkMobility.Text
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Defines the types of delivery methods on a report.
|
/// Defines the types of delivery methods on a report.
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
using Newtonsoft.Json.Converters;
|
using Newtonsoft.Json.Converters;
|
||||||
|
|
||||||
namespace AMWD.Net.Api.LinkMobility
|
namespace AMWD.Net.Api.LinkMobility.Text
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Specifies the message type.
|
/// Specifies the message type.
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace AMWD.Net.Api.LinkMobility
|
namespace AMWD.Net.Api.LinkMobility.Text
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Request to send a text message to a list of recipients.
|
/// Request to send a text message to a list of recipients.
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace AMWD.Net.Api.LinkMobility
|
namespace AMWD.Net.Api.LinkMobility.Text
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Request to send a text message to a list of recipients.
|
/// Request to send a text message to a list of recipients.
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using AMWD.Net.Api.LinkMobility.Utils;
|
using AMWD.Net.Api.LinkMobility.Utils;
|
||||||
|
|
||||||
namespace AMWD.Net.Api.LinkMobility
|
namespace AMWD.Net.Api.LinkMobility.Text
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Implementation of text messaging (SMS). <see href="https://developer.linkmobility.eu/sms-api/rest-api">API</see>
|
/// Implementation of text messaging (SMS). <see href="https://developer.linkmobility.eu/sms-api/rest-api">API</see>
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
|
||||||
namespace AMWD.Net.Api.LinkMobility
|
namespace AMWD.Net.Api.LinkMobility.Utils
|
||||||
{
|
{
|
||||||
internal static class SerializerExtensions
|
internal static class SerializerExtensions
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,9 +1,15 @@
|
|||||||
namespace AMWD.Net.Api.LinkMobility
|
using AMWD.Net.Api.LinkMobility.Utils;
|
||||||
|
|
||||||
|
namespace AMWD.Net.Api.LinkMobility.Webhook
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Representes the response to an incoming message notification. (<see href="https://developer.linkmobility.eu/sms-api/receive-incoming-messages">API</see>)
|
/// Representes the response to an incoming message notification.
|
||||||
|
/// (See <see href="https://developer.linkmobility.eu/sms-api/receive-incoming-messages">API</see>)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class IncomingMessageNotificationResponse
|
/// <remarks>
|
||||||
|
/// This notification acknowlegement is the same for all webhooks of LINK Mobility.
|
||||||
|
/// </remarks>
|
||||||
|
public class NotificationResponse
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the status code of the response.
|
/// Gets or sets the status code of the response.
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
using Newtonsoft.Json.Converters;
|
using Newtonsoft.Json.Converters;
|
||||||
|
|
||||||
namespace AMWD.Net.Api.LinkMobility
|
namespace AMWD.Net.Api.LinkMobility.Webhook.Text
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Defines the delivery status of a message on a report.
|
/// Defines the delivery status of a message on a report.
|
||||||
30
src/LinkMobility/Webhook/Text/TextMessageType.cs
Normal file
30
src/LinkMobility/Webhook/Text/TextMessageType.cs
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
using System.Runtime.Serialization;
|
||||||
|
using Newtonsoft.Json.Converters;
|
||||||
|
|
||||||
|
namespace AMWD.Net.Api.LinkMobility.Webhook.Text
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Defines the type of notification.
|
||||||
|
/// </summary>
|
||||||
|
[JsonConverter(typeof(StringEnumConverter))]
|
||||||
|
public enum TextMessageType
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Notification of an incoming text message.
|
||||||
|
/// </summary>
|
||||||
|
[EnumMember(Value = "text")]
|
||||||
|
Text = 1,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Notification of an incoming binary message.
|
||||||
|
/// </summary>
|
||||||
|
[EnumMember(Value = "binary")]
|
||||||
|
Binary = 2,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Notification of a delivery report.
|
||||||
|
/// </summary>
|
||||||
|
[EnumMember(Value = "deliveryReport")]
|
||||||
|
DeliveryReport = 3
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,19 +1,20 @@
|
|||||||
using System.Runtime.Serialization;
|
using AMWD.Net.Api.LinkMobility.Text;
|
||||||
using Newtonsoft.Json.Converters;
|
using AMWD.Net.Api.LinkMobility.Utils;
|
||||||
|
|
||||||
namespace AMWD.Net.Api.LinkMobility
|
namespace AMWD.Net.Api.LinkMobility.Webhook.Text
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a notification for an incoming message or delivery report. (<see href="https://developer.linkmobility.eu/sms-api/receive-incoming-messages">API</see>)
|
/// Represents a notification for an incoming text message or delivery report.
|
||||||
|
/// (<see href="https://developer.linkmobility.eu/sms-api/receive-incoming-messages">API</see>)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class IncomingMessageNotification
|
public class TextNotification
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="IncomingMessageNotification"/> class.
|
/// Initializes a new instance of the <see cref="TextNotification"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="notificationId">The notification id.</param>
|
/// <param name="notificationId">The notification id.</param>
|
||||||
/// <param name="transferId">The transfer id.</param>
|
/// <param name="transferId">The transfer id.</param>
|
||||||
public IncomingMessageNotification(string notificationId, string transferId)
|
public TextNotification(string notificationId, string transferId)
|
||||||
{
|
{
|
||||||
NotificationId = notificationId;
|
NotificationId = notificationId;
|
||||||
TransferId = transferId;
|
TransferId = transferId;
|
||||||
@@ -23,7 +24,7 @@ namespace AMWD.Net.Api.LinkMobility
|
|||||||
/// Defines the content type of your notification.
|
/// Defines the content type of your notification.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonProperty("messageType")]
|
[JsonProperty("messageType")]
|
||||||
public Type MessageType { get; set; }
|
public TextMessageType MessageType { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 20 digit long identification of your notification.
|
/// 20 digit long identification of your notification.
|
||||||
@@ -32,7 +33,7 @@ namespace AMWD.Net.Api.LinkMobility
|
|||||||
public string NotificationId { get; set; }
|
public string NotificationId { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <see cref="Type.DeliveryReport"/>:
|
/// <see cref="Text.TextMessageType.DeliveryReport"/>:
|
||||||
/// <br/>
|
/// <br/>
|
||||||
/// Unique transfer-id to connect the deliveryReport to the initial message.
|
/// Unique transfer-id to connect the deliveryReport to the initial message.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -40,7 +41,7 @@ namespace AMWD.Net.Api.LinkMobility
|
|||||||
public string TransferId { get; set; }
|
public string TransferId { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <see cref="Type.Text"/>, <see cref="Type.Binary"/>:
|
/// <see cref="Text.TextMessageType.Text"/>, <see cref="Text.TextMessageType.Binary"/>:
|
||||||
/// <br/>
|
/// <br/>
|
||||||
/// Indicates whether you received message is a SMS or a flash-SMS.
|
/// Indicates whether you received message is a SMS or a flash-SMS.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -54,7 +55,7 @@ namespace AMWD.Net.Api.LinkMobility
|
|||||||
public string? SenderAddress { get; set; }
|
public string? SenderAddress { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <see cref="Type.Text"/>, <see cref="Type.Binary"/>:
|
/// <see cref="Text.TextMessageType.Text"/>, <see cref="Text.TextMessageType.Binary"/>:
|
||||||
/// <br/>
|
/// <br/>
|
||||||
/// <see cref="AddressType.International"/> - defines the number format of the mobile originated <see cref="SenderAddress"/>.
|
/// <see cref="AddressType.International"/> - defines the number format of the mobile originated <see cref="SenderAddress"/>.
|
||||||
/// International numbers always includes the country prefix.
|
/// International numbers always includes the country prefix.
|
||||||
@@ -72,7 +73,7 @@ namespace AMWD.Net.Api.LinkMobility
|
|||||||
public string? RecipientAddress { get; set; }
|
public string? RecipientAddress { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <see cref="Type.Text"/>, <see cref="Type.Binary"/>:
|
/// <see cref="Text.TextMessageType.Text"/>, <see cref="Text.TextMessageType.Binary"/>:
|
||||||
/// <br/>
|
/// <br/>
|
||||||
/// Defines the number format of the mobile originated message.
|
/// Defines the number format of the mobile originated message.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -80,7 +81,7 @@ namespace AMWD.Net.Api.LinkMobility
|
|||||||
public AddressType? RecipientAddressType { get; set; }
|
public AddressType? RecipientAddressType { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <see cref="Type.Text"/>:
|
/// <see cref="Text.TextMessageType.Text"/>:
|
||||||
/// <br/>
|
/// <br/>
|
||||||
/// Text body of the message encoded in <c>UTF-8</c>.
|
/// Text body of the message encoded in <c>UTF-8</c>.
|
||||||
/// In the case of concatenated SMS it will contain the complete content of all segments.
|
/// In the case of concatenated SMS it will contain the complete content of all segments.
|
||||||
@@ -89,7 +90,7 @@ namespace AMWD.Net.Api.LinkMobility
|
|||||||
public string? TextMessageContent { get; set; }
|
public string? TextMessageContent { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <see cref="Type.Binary"/>:
|
/// <see cref="Text.TextMessageType.Binary"/>:
|
||||||
/// <br/>
|
/// <br/>
|
||||||
/// Indicates whether a user-data-header is included within a <c>Base64</c> encoded byte segment.
|
/// Indicates whether a user-data-header is included within a <c>Base64</c> encoded byte segment.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -97,7 +98,7 @@ namespace AMWD.Net.Api.LinkMobility
|
|||||||
public bool? UserDataHeaderPresent { get; set; }
|
public bool? UserDataHeaderPresent { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <see cref="Type.Binary"/>:
|
/// <see cref="Text.TextMessageType.Binary"/>:
|
||||||
/// <br/>
|
/// <br/>
|
||||||
/// Content of a binary SMS in an array of <c>Base64</c> strings (URL safe).
|
/// Content of a binary SMS in an array of <c>Base64</c> strings (URL safe).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -105,7 +106,7 @@ namespace AMWD.Net.Api.LinkMobility
|
|||||||
public IReadOnlyCollection<string>? BinaryMessageContent { get; set; }
|
public IReadOnlyCollection<string>? BinaryMessageContent { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <see cref="Type.DeliveryReport"/>:
|
/// <see cref="Text.TextMessageType.DeliveryReport"/>:
|
||||||
/// <br/>
|
/// <br/>
|
||||||
/// Status of the message.
|
/// Status of the message.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -113,7 +114,7 @@ namespace AMWD.Net.Api.LinkMobility
|
|||||||
public DeliveryStatus? DeliveryReportMessageStatus { get; set; }
|
public DeliveryStatus? DeliveryReportMessageStatus { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <see cref="Type.DeliveryReport"/>:
|
/// <see cref="Text.TextMessageType.DeliveryReport"/>:
|
||||||
/// <br/>
|
/// <br/>
|
||||||
/// ISO 8601 timestamp. Point of time sending the message to recipients address.
|
/// ISO 8601 timestamp. Point of time sending the message to recipients address.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -121,7 +122,7 @@ namespace AMWD.Net.Api.LinkMobility
|
|||||||
public DateTime? SentOn { get; set; }
|
public DateTime? SentOn { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <see cref="Type.DeliveryReport"/>:
|
/// <see cref="Text.TextMessageType.DeliveryReport"/>:
|
||||||
/// <br/>
|
/// <br/>
|
||||||
/// ISO 8601 timestamp. Point of time of submitting the message to the mobile operators network.
|
/// ISO 8601 timestamp. Point of time of submitting the message to the mobile operators network.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -129,7 +130,7 @@ namespace AMWD.Net.Api.LinkMobility
|
|||||||
public DateTime? DeliveredOn { get; set; }
|
public DateTime? DeliveredOn { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <see cref="Type.DeliveryReport"/>:
|
/// <see cref="Text.TextMessageType.DeliveryReport"/>:
|
||||||
/// <br/>
|
/// <br/>
|
||||||
/// Type of delivery used to send the message.
|
/// Type of delivery used to send the message.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -137,7 +138,7 @@ namespace AMWD.Net.Api.LinkMobility
|
|||||||
public DeliveryType? DeliveredAs { get; set; }
|
public DeliveryType? DeliveredAs { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <see cref="Type.DeliveryReport"/>:
|
/// <see cref="Text.TextMessageType.DeliveryReport"/>:
|
||||||
/// <br/>
|
/// <br/>
|
||||||
/// In the case of a delivery report, the <see cref="ClientMessageId"/> contains the optional submitted message id.
|
/// In the case of a delivery report, the <see cref="ClientMessageId"/> contains the optional submitted message id.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -145,43 +146,18 @@ namespace AMWD.Net.Api.LinkMobility
|
|||||||
public string? ClientMessageId { get; set; }
|
public string? ClientMessageId { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Defines the type of notification.
|
/// Tries to parse the given content as <see cref="TextNotification"/>.
|
||||||
/// </summary>
|
|
||||||
[JsonConverter(typeof(StringEnumConverter))]
|
|
||||||
public enum Type
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Notification of an incoming text message.
|
|
||||||
/// </summary>
|
|
||||||
[EnumMember(Value = "text")]
|
|
||||||
Text = 1,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Notification of an incoming binary message.
|
|
||||||
/// </summary>
|
|
||||||
[EnumMember(Value = "binary")]
|
|
||||||
Binary = 2,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Notification of a delivery report.
|
|
||||||
/// </summary>
|
|
||||||
[EnumMember(Value = "deliveryReport")]
|
|
||||||
DeliveryReport = 3
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Tries to parse the given content as <see cref="IncomingMessageNotification"/>.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="json">The given content (should be the notification json).</param>
|
/// <param name="json">The given content (should be the notification json).</param>
|
||||||
/// <param name="notification">The deserialized notification.</param>
|
/// <param name="notification">The deserialized notification.</param>
|
||||||
/// <returns>
|
/// <returns>
|
||||||
/// <see langword="true"/> if the content could be parsed; otherwise, <see langword="false"/>.
|
/// <see langword="true"/> if the content could be parsed; otherwise, <see langword="false"/>.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public static bool TryParse(string json, out IncomingMessageNotification? notification)
|
public static bool TryParse(string json, out TextNotification? notification)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
notification = json.DeserializeObject<IncomingMessageNotification>();
|
notification = json.DeserializeObject<TextNotification>();
|
||||||
return notification != null;
|
return notification != null;
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
@@ -145,7 +145,7 @@ namespace LinkMobility.Tests
|
|||||||
var client = GetClient();
|
var client = GetClient();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var response = await client.PostAsync<TestClass, TestClass>("test", _request, null, TestContext.CancellationToken);
|
var response = await client.PostAsync<TestClass, TestClass>("test", _request, TestContext.CancellationToken);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.IsNotNull(response);
|
Assert.IsNotNull(response);
|
||||||
@@ -166,57 +166,12 @@ namespace LinkMobility.Tests
|
|||||||
Assert.AreEqual("Scheme Parameter", callback.Headers["Authorization"]);
|
Assert.AreEqual("Scheme Parameter", callback.Headers["Authorization"]);
|
||||||
Assert.AreEqual("LinkMobilityClient/1.0.0", callback.Headers["User-Agent"]);
|
Assert.AreEqual("LinkMobilityClient/1.0.0", callback.Headers["User-Agent"]);
|
||||||
|
|
||||||
_httpMessageHandlerMock.Mock
|
_httpMessageHandlerMock.Protected.Verify("SendAsync", Times.Once(), ItExpr.IsAny<HttpRequestMessage>(), ItExpr.IsAny<CancellationToken>());
|
||||||
.Protected()
|
|
||||||
.Verify("SendAsync", Times.Once(), ItExpr.IsAny<HttpRequestMessage>(), ItExpr.IsAny<CancellationToken>());
|
|
||||||
|
|
||||||
_clientOptionsMock.VerifyGet(o => o.DefaultQueryParams, Times.Exactly(2));
|
_clientOptionsMock.VerifyGet(o => o.DefaultQueryParams, Times.Exactly(2));
|
||||||
VerifyNoOtherCalls();
|
VerifyNoOtherCalls();
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public async Task ShouldAddCustomQueryParameters()
|
|
||||||
{
|
|
||||||
// Arrange
|
|
||||||
var queryParams = new TestParams();
|
|
||||||
_httpMessageHandlerMock.Responses.Enqueue(new HttpResponseMessage
|
|
||||||
{
|
|
||||||
StatusCode = HttpStatusCode.OK,
|
|
||||||
Content = new StringContent(@"{ ""string"": ""some-string"", ""integer"": 123 }", Encoding.UTF8, "application/json"),
|
|
||||||
});
|
|
||||||
|
|
||||||
var client = GetClient();
|
|
||||||
|
|
||||||
// Act
|
|
||||||
var response = await client.PostAsync<TestClass, TestClass>("params/path", _request, queryParams, TestContext.CancellationToken);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
Assert.IsNotNull(response);
|
|
||||||
|
|
||||||
Assert.HasCount(1, _httpMessageHandlerMock.RequestCallbacks);
|
|
||||||
|
|
||||||
var callback = _httpMessageHandlerMock.RequestCallbacks.First();
|
|
||||||
Assert.AreEqual(HttpMethod.Post, callback.HttpMethod);
|
|
||||||
Assert.AreEqual("https://localhost/rest/params/path?test=query+text", callback.Url);
|
|
||||||
Assert.AreEqual(@"{""string"":""Happy Testing"",""integer"":54321}", callback.Content);
|
|
||||||
|
|
||||||
Assert.HasCount(3, callback.Headers);
|
|
||||||
Assert.IsTrue(callback.Headers.ContainsKey("Accept"));
|
|
||||||
Assert.IsTrue(callback.Headers.ContainsKey("Authorization"));
|
|
||||||
Assert.IsTrue(callback.Headers.ContainsKey("User-Agent"));
|
|
||||||
|
|
||||||
Assert.AreEqual("application/json", callback.Headers["Accept"]);
|
|
||||||
Assert.AreEqual("Scheme Parameter", callback.Headers["Authorization"]);
|
|
||||||
Assert.AreEqual("LinkMobilityClient/1.0.0", callback.Headers["User-Agent"]);
|
|
||||||
|
|
||||||
_httpMessageHandlerMock.Mock
|
|
||||||
.Protected()
|
|
||||||
.Verify("SendAsync", Times.Once(), ItExpr.IsAny<HttpRequestMessage>(), ItExpr.IsAny<CancellationToken>());
|
|
||||||
|
|
||||||
_clientOptionsMock.VerifyGet(o => o.DefaultQueryParams, Times.Once);
|
|
||||||
VerifyNoOtherCalls();
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void ShouldDisposeHttpClient()
|
public void ShouldDisposeHttpClient()
|
||||||
{
|
{
|
||||||
@@ -227,9 +182,7 @@ namespace LinkMobility.Tests
|
|||||||
client.Dispose();
|
client.Dispose();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
_httpMessageHandlerMock.Mock
|
_httpMessageHandlerMock.Protected.Verify("Dispose", Times.Once(), exactParameterMatch: true, true);
|
||||||
.Protected()
|
|
||||||
.Verify("Dispose", Times.Once(), exactParameterMatch: true, true);
|
|
||||||
|
|
||||||
VerifyNoOtherCalls();
|
VerifyNoOtherCalls();
|
||||||
}
|
}
|
||||||
@@ -245,9 +198,7 @@ namespace LinkMobility.Tests
|
|||||||
client.Dispose();
|
client.Dispose();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
_httpMessageHandlerMock.Mock
|
_httpMessageHandlerMock.Protected.Verify("Dispose", Times.Once(), exactParameterMatch: true, true);
|
||||||
.Protected()
|
|
||||||
.Verify("Dispose", Times.Once(), exactParameterMatch: true, true);
|
|
||||||
|
|
||||||
VerifyNoOtherCalls();
|
VerifyNoOtherCalls();
|
||||||
}
|
}
|
||||||
@@ -320,7 +271,7 @@ namespace LinkMobility.Tests
|
|||||||
// Act & Assert
|
// Act & Assert
|
||||||
await Assert.ThrowsExactlyAsync<ObjectDisposedException>(async () =>
|
await Assert.ThrowsExactlyAsync<ObjectDisposedException>(async () =>
|
||||||
{
|
{
|
||||||
await client.PostAsync<object, TestClass>("/request/path", _request, null, TestContext.CancellationToken);
|
await client.PostAsync<object, TestClass>("/request/path", _request, TestContext.CancellationToken);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -336,7 +287,7 @@ namespace LinkMobility.Tests
|
|||||||
// Act & Assert
|
// Act & Assert
|
||||||
await Assert.ThrowsExactlyAsync<ArgumentNullException>(async () =>
|
await Assert.ThrowsExactlyAsync<ArgumentNullException>(async () =>
|
||||||
{
|
{
|
||||||
await client.PostAsync<object, TestClass>(path, _request, null, TestContext.CancellationToken);
|
await client.PostAsync<object, TestClass>(path, _request, TestContext.CancellationToken);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -349,7 +300,7 @@ namespace LinkMobility.Tests
|
|||||||
// Act & Assert
|
// Act & Assert
|
||||||
await Assert.ThrowsExactlyAsync<ArgumentException>(async () =>
|
await Assert.ThrowsExactlyAsync<ArgumentException>(async () =>
|
||||||
{
|
{
|
||||||
await client.PostAsync<object, TestClass>("foo?bar=baz", _request, null, TestContext.CancellationToken);
|
await client.PostAsync<object, TestClass>("foo?bar=baz", _request, TestContext.CancellationToken);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -366,7 +317,7 @@ namespace LinkMobility.Tests
|
|||||||
var client = GetClient();
|
var client = GetClient();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var response = await client.PostAsync<TestClass, TestClass>("/request/path", _request, null, TestContext.CancellationToken);
|
var response = await client.PostAsync<TestClass, TestClass>("/request/path", _request, TestContext.CancellationToken);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.IsNotNull(response);
|
Assert.IsNotNull(response);
|
||||||
@@ -389,9 +340,7 @@ namespace LinkMobility.Tests
|
|||||||
Assert.AreEqual("Scheme Parameter", callback.Headers["Authorization"]);
|
Assert.AreEqual("Scheme Parameter", callback.Headers["Authorization"]);
|
||||||
Assert.AreEqual("LinkMobilityClient/1.0.0", callback.Headers["User-Agent"]);
|
Assert.AreEqual("LinkMobilityClient/1.0.0", callback.Headers["User-Agent"]);
|
||||||
|
|
||||||
_httpMessageHandlerMock.Mock
|
_httpMessageHandlerMock.Protected.Verify("SendAsync", Times.Once(), ItExpr.IsAny<HttpRequestMessage>(), ItExpr.IsAny<CancellationToken>());
|
||||||
.Protected()
|
|
||||||
.Verify("SendAsync", Times.Once(), ItExpr.IsAny<HttpRequestMessage>(), ItExpr.IsAny<CancellationToken>());
|
|
||||||
|
|
||||||
_clientOptionsMock.VerifyGet(o => o.DefaultQueryParams, Times.Once);
|
_clientOptionsMock.VerifyGet(o => o.DefaultQueryParams, Times.Once);
|
||||||
VerifyNoOtherCalls();
|
VerifyNoOtherCalls();
|
||||||
@@ -411,7 +360,7 @@ namespace LinkMobility.Tests
|
|||||||
var client = GetClient();
|
var client = GetClient();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var response = await client.PostAsync<TestClass, HttpContent>("/request/path", stringContent, null, TestContext.CancellationToken);
|
var response = await client.PostAsync<TestClass, HttpContent>("/request/path", stringContent, TestContext.CancellationToken);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.IsNotNull(response);
|
Assert.IsNotNull(response);
|
||||||
@@ -434,9 +383,7 @@ namespace LinkMobility.Tests
|
|||||||
Assert.AreEqual("Scheme Parameter", callback.Headers["Authorization"]);
|
Assert.AreEqual("Scheme Parameter", callback.Headers["Authorization"]);
|
||||||
Assert.AreEqual("LinkMobilityClient/1.0.0", callback.Headers["User-Agent"]);
|
Assert.AreEqual("LinkMobilityClient/1.0.0", callback.Headers["User-Agent"]);
|
||||||
|
|
||||||
_httpMessageHandlerMock.Mock
|
_httpMessageHandlerMock.Protected.Verify("SendAsync", Times.Once(), ItExpr.IsAny<HttpRequestMessage>(), ItExpr.IsAny<CancellationToken>());
|
||||||
.Protected()
|
|
||||||
.Verify("SendAsync", Times.Once(), ItExpr.IsAny<HttpRequestMessage>(), ItExpr.IsAny<CancellationToken>());
|
|
||||||
|
|
||||||
_clientOptionsMock.VerifyGet(o => o.DefaultQueryParams, Times.Once);
|
_clientOptionsMock.VerifyGet(o => o.DefaultQueryParams, Times.Once);
|
||||||
VerifyNoOtherCalls();
|
VerifyNoOtherCalls();
|
||||||
@@ -455,7 +402,7 @@ namespace LinkMobility.Tests
|
|||||||
var client = GetClient();
|
var client = GetClient();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var response = await client.PostAsync<TestClass, object>("posting", null, null, TestContext.CancellationToken);
|
var response = await client.PostAsync<TestClass, object>("posting", null, TestContext.CancellationToken);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.IsNotNull(response);
|
Assert.IsNotNull(response);
|
||||||
@@ -479,9 +426,7 @@ namespace LinkMobility.Tests
|
|||||||
Assert.AreEqual("Scheme Parameter", callback.Headers["Authorization"]);
|
Assert.AreEqual("Scheme Parameter", callback.Headers["Authorization"]);
|
||||||
Assert.AreEqual("LinkMobilityClient/1.0.0", callback.Headers["User-Agent"]);
|
Assert.AreEqual("LinkMobilityClient/1.0.0", callback.Headers["User-Agent"]);
|
||||||
|
|
||||||
_httpMessageHandlerMock.Mock
|
_httpMessageHandlerMock.Protected.Verify("SendAsync", Times.Once(), ItExpr.IsAny<HttpRequestMessage>(), ItExpr.IsAny<CancellationToken>());
|
||||||
.Protected()
|
|
||||||
.Verify("SendAsync", Times.Once(), ItExpr.IsAny<HttpRequestMessage>(), ItExpr.IsAny<CancellationToken>());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
@@ -501,7 +446,7 @@ namespace LinkMobility.Tests
|
|||||||
// Act & Assert
|
// Act & Assert
|
||||||
var ex = await Assert.ThrowsExactlyAsync<AuthenticationException>(async () =>
|
var ex = await Assert.ThrowsExactlyAsync<AuthenticationException>(async () =>
|
||||||
{
|
{
|
||||||
await client.PostAsync<object, TestClass>("foo", _request, null, TestContext.CancellationToken);
|
await client.PostAsync<object, TestClass>("foo", _request, TestContext.CancellationToken);
|
||||||
});
|
});
|
||||||
Assert.IsNull(ex.InnerException);
|
Assert.IsNull(ex.InnerException);
|
||||||
Assert.AreEqual($"HTTP auth missing: {statusCode}", ex.Message);
|
Assert.AreEqual($"HTTP auth missing: {statusCode}", ex.Message);
|
||||||
@@ -524,7 +469,7 @@ namespace LinkMobility.Tests
|
|||||||
// Act & Assert
|
// Act & Assert
|
||||||
var ex = await Assert.ThrowsExactlyAsync<ApplicationException>(async () =>
|
var ex = await Assert.ThrowsExactlyAsync<ApplicationException>(async () =>
|
||||||
{
|
{
|
||||||
await client.PostAsync<object, TestClass>("foo", _request, null, TestContext.CancellationToken);
|
await client.PostAsync<object, TestClass>("foo", _request, TestContext.CancellationToken);
|
||||||
});
|
});
|
||||||
Assert.IsNull(ex.InnerException);
|
Assert.IsNull(ex.InnerException);
|
||||||
Assert.AreEqual($"Unknown HTTP response: {statusCode}", ex.Message);
|
Assert.AreEqual($"Unknown HTTP response: {statusCode}", ex.Message);
|
||||||
@@ -545,7 +490,7 @@ namespace LinkMobility.Tests
|
|||||||
// Act & Assert
|
// Act & Assert
|
||||||
await Assert.ThrowsExactlyAsync<JsonReaderException>(async () =>
|
await Assert.ThrowsExactlyAsync<JsonReaderException>(async () =>
|
||||||
{
|
{
|
||||||
await client.PostAsync<TestClass, TestClass>("some-path", _request, null, TestContext.CancellationToken);
|
await client.PostAsync<TestClass, TestClass>("some-path", _request, TestContext.CancellationToken);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -563,7 +508,7 @@ namespace LinkMobility.Tests
|
|||||||
var client = GetClient();
|
var client = GetClient();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
string response = await client.PostAsync<string, TestClass>("path", _request, null, TestContext.CancellationToken);
|
string response = await client.PostAsync<string, TestClass>("path", _request, TestContext.CancellationToken);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.IsNotNull(response);
|
Assert.IsNotNull(response);
|
||||||
@@ -586,9 +531,7 @@ namespace LinkMobility.Tests
|
|||||||
Assert.AreEqual("Scheme Parameter", callback.Headers["Authorization"]);
|
Assert.AreEqual("Scheme Parameter", callback.Headers["Authorization"]);
|
||||||
Assert.AreEqual("LinkMobilityClient/1.0.0", callback.Headers["User-Agent"]);
|
Assert.AreEqual("LinkMobilityClient/1.0.0", callback.Headers["User-Agent"]);
|
||||||
|
|
||||||
_httpMessageHandlerMock.Mock
|
_httpMessageHandlerMock.Protected.Verify("SendAsync", Times.Once(), ItExpr.IsAny<HttpRequestMessage>(), ItExpr.IsAny<CancellationToken>());
|
||||||
.Protected()
|
|
||||||
.Verify("SendAsync", Times.Once(), ItExpr.IsAny<HttpRequestMessage>(), ItExpr.IsAny<CancellationToken>());
|
|
||||||
|
|
||||||
_clientOptionsMock.VerifyGet(o => o.DefaultQueryParams, Times.Once);
|
_clientOptionsMock.VerifyGet(o => o.DefaultQueryParams, Times.Once);
|
||||||
VerifyNoOtherCalls();
|
VerifyNoOtherCalls();
|
||||||
@@ -638,16 +581,5 @@ namespace LinkMobility.Tests
|
|||||||
[JsonProperty("integer")]
|
[JsonProperty("integer")]
|
||||||
public int Int { get; set; }
|
public int Int { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TestParams : IQueryParameter
|
|
||||||
{
|
|
||||||
public IReadOnlyDictionary<string, string> GetQueryParameters()
|
|
||||||
{
|
|
||||||
return new Dictionary<string, string>
|
|
||||||
{
|
|
||||||
{ "test", "query text" }
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,10 +6,11 @@ using System.Text;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using AMWD.Net.Api.LinkMobility;
|
using AMWD.Net.Api.LinkMobility;
|
||||||
|
using AMWD.Net.Api.LinkMobility.Text;
|
||||||
using LinkMobility.Tests.Helpers;
|
using LinkMobility.Tests.Helpers;
|
||||||
using Moq.Protected;
|
using Moq.Protected;
|
||||||
|
|
||||||
namespace LinkMobility.Tests.Sms
|
namespace LinkMobility.Tests.Text
|
||||||
{
|
{
|
||||||
[TestClass]
|
[TestClass]
|
||||||
public class SendBinaryMessageTest
|
public class SendBinaryMessageTest
|
||||||
@@ -6,10 +6,11 @@ using System.Text;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using AMWD.Net.Api.LinkMobility;
|
using AMWD.Net.Api.LinkMobility;
|
||||||
|
using AMWD.Net.Api.LinkMobility.Text;
|
||||||
using LinkMobility.Tests.Helpers;
|
using LinkMobility.Tests.Helpers;
|
||||||
using Moq.Protected;
|
using Moq.Protected;
|
||||||
|
|
||||||
namespace LinkMobility.Tests.Sms
|
namespace LinkMobility.Tests.Text
|
||||||
{
|
{
|
||||||
[TestClass]
|
[TestClass]
|
||||||
public class SendTextMessageTest
|
public class SendTextMessageTest
|
||||||
@@ -1,9 +1,10 @@
|
|||||||
using AMWD.Net.Api.LinkMobility;
|
using AMWD.Net.Api.LinkMobility.Text;
|
||||||
|
using AMWD.Net.Api.LinkMobility.Webhook.Text;
|
||||||
|
|
||||||
namespace LinkMobility.Tests.Models
|
namespace LinkMobility.Tests.Webhook.Text
|
||||||
{
|
{
|
||||||
[TestClass]
|
[TestClass]
|
||||||
public class IncomingMessageNotificationTest
|
public class TextNotificationTest
|
||||||
{
|
{
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void ShouldParseAllPropertiesForTextNotification()
|
public void ShouldParseAllPropertiesForTextNotification()
|
||||||
@@ -29,13 +30,13 @@ namespace LinkMobility.Tests.Models
|
|||||||
}";
|
}";
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
bool successful = IncomingMessageNotification.TryParse(json, out var notification);
|
bool successful = TextNotification.TryParse(json, out var notification);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.IsTrue(successful, "TryParse should return true for valid json");
|
Assert.IsTrue(successful, "TryParse should return true for valid json");
|
||||||
Assert.IsNotNull(notification);
|
Assert.IsNotNull(notification);
|
||||||
|
|
||||||
Assert.AreEqual(IncomingMessageNotification.Type.Text, notification.MessageType);
|
Assert.AreEqual(TextMessageType.Text, notification.MessageType);
|
||||||
Assert.AreEqual("notif-123", notification.NotificationId);
|
Assert.AreEqual("notif-123", notification.NotificationId);
|
||||||
Assert.AreEqual("trans-456", notification.TransferId);
|
Assert.AreEqual("trans-456", notification.TransferId);
|
||||||
|
|
||||||
@@ -80,7 +81,7 @@ namespace LinkMobility.Tests.Models
|
|||||||
string invalid = "this is not json";
|
string invalid = "this is not json";
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
bool successful = IncomingMessageNotification.TryParse(invalid, out var notification);
|
bool successful = TextNotification.TryParse(invalid, out var notification);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.IsFalse(successful);
|
Assert.IsFalse(successful);
|
||||||
Reference in New Issue
Block a user