refactor(Extensions): move to common
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
using EnvelopeGenerator.Application.Common.Dto.Messaging;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Common.Extensions;
|
||||
|
||||
/// <summary>
|
||||
/// Provides extension methods for common mapping and conversion operations.
|
||||
/// </summary>
|
||||
public static class MappingExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Determines whether the response indicates a successful "OK" message status.
|
||||
/// </summary>
|
||||
/// <param name="gtxMessagingResponse">The response object to evaluate.</param>
|
||||
/// <returns><see langword="true"/> if the response contains a "message-status" key with a value of "ok" (case-insensitive);
|
||||
/// otherwise, <see langword="false"/>.</returns>
|
||||
public static bool Ok(this GtxMessagingResponse gtxMessagingResponse)
|
||||
=> gtxMessagingResponse.TryGetValue("message-status", out var status)
|
||||
&& status?.ToString()?.ToLower() == "ok";
|
||||
|
||||
/// <summary>
|
||||
/// Converts the specified byte array to its equivalent string representation encoded in base-64.
|
||||
/// </summary>
|
||||
/// <param name="bytes">The byte array to encode.</param>
|
||||
/// <returns>A base-64 encoded string representation of the input byte array.</returns>
|
||||
public static string ToBase64String(this byte[] bytes)
|
||||
=> Convert.ToBase64String(bytes);
|
||||
}
|
||||
Reference in New Issue
Block a user