Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/SampleApp/Sample/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ static async IAsyncEnumerable<Response> ProcessMessagesAsync(

// simulate some hard work at hand, like doing some LLM-stuff :)
//await Task.Delay(2000);
yield return content.TextWithButtons(
yield return content.Text(
$"☑️ Got your {content.Content.Type}:\r\n{JsonSerializer.Serialize(content, options)}",
new Button("btn_good", "👍"),
new Button("btn_bad", "👎"));
Expand Down
12 changes: 6 additions & 6 deletions src/WhatsApp/MessageExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,25 @@ public static partial class MessageExtensions
/// Creates a reaction response for the user message.
/// </summary>
public static ReactionResponse React(this UserMessage message, string emoji)
=> new ReactionResponse(message.From.Number, message.To.Id, message.Id, message.ConversationId, emoji);
=> new(message.From.Number, message.To.Id, message.Id, message.ConversationId, emoji);

/// <summary>
/// Creates a reengagement response for the error message.
/// </summary>
public static TemplateResponse Reengage(this ErrorMessage message)
=> new TemplateResponse(message.From.Number, message.To.Id, message.Id, message.ConversationId, "reengagement", "es_AR");
=> new(message.From.Number, message.To.Id, message.Id, message.ConversationId, "reengagement", "es_AR");

/// <summary>
/// Creates a text response for the message.
/// </summary>
public static TextResponse Text(this Message message, string text)
=> new TextResponse(message.From.Number, message.To.Id, message.Id, message.ConversationId, text);
=> new(message.From.Number, message.To.Id, message.Id, message.ConversationId, text);

/// <summary>
/// Creates a text response with buttons for the message.
/// </summary>
public static TextResponse TextWithButtons(this Message message, string text, Button button1, Button? button2 = default)
=> new TextResponse(message.From.Number, message.To.Id, message.Id, message.ConversationId, text, button1, button2);
public static TextResponse Text(this Message message, string text, Button button1, Button? button2 = default)
=> new(message.From.Number, message.To.Id, message.Id, message.ConversationId, text, button1, button2);

/// <summary>
/// Attempts to retrieve a single message from the specified collection.
Expand All @@ -42,7 +42,7 @@ public static TextResponse TextWithButtons(this Message message, string text, Bu
/// <param name="message">When this method returns <see langword="true"/>, contains the single message from the collection. When this
/// method returns <see langword="false"/>, contains <see langword="null"/>.</param>
/// <returns><see langword="true"/> if the collection contains exactly one message; otherwise, <see langword="false"/>.</returns>
public static bool TrySingle(this IEnumerable<IMessage> messages, [NotNullWhen(true)] out IMessage? message)
internal static bool TrySingle(this IEnumerable<IMessage> messages, [NotNullWhen(true)] out IMessage? message)
{
if (messages is IList<IMessage> list && list.Count == 1)
{
Expand Down
2 changes: 1 addition & 1 deletion src/WhatsApp/ReactionResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/// <remarks>This response is used to react to a message by sending an emoji. The reaction is associated with a
/// specific message identified by the <see cref="Context"/> property in the context of a conversation.</remarks>
/// <param name="Number">The phone number of the recipient in international format.</param>
/// <param name="ServiceId">The identifier of the service handling the message.</param>
/// <param name="Service">The identifier of the service handling the message.</param>
/// <param name="Context">The unique identifier of the message to which the reaction is being sent.</param>
/// <param name="Emoji">The emoji representing the reaction to the message.</param>
public record ReactionResponse(string Number, string Service, string Context, string? ConversationId, string Emoji) : Response(Number, Service, Context, ConversationId)
Expand Down
7 changes: 2 additions & 5 deletions src/WhatsApp/Response.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System.Text.Json.Serialization;
using Microsoft.AspNetCore.Mvc;

namespace Devlooped.WhatsApp;
namespace Devlooped.WhatsApp;

/// <summary>
/// Represents a response message or command that can be sent using a WhatsApp client.
Expand All @@ -11,7 +8,7 @@ namespace Devlooped.WhatsApp;
/// <see cref="Context"/>, and <see cref="ConversationId"/>, as well as methods for sending the response
/// asynchronously.</remarks>
/// <param name="Number">The phone number of the recipient in international format.</param>
/// <param name="ServiceId">The identifier of the service handling the message.</param>
/// <param name="Service">The identifier of the service handling the message.</param>
/// <param name="Context">The unique identifier of the message to which the reaction is being sent.</param>
/// <param name="ConversationId">The conversation id where this response was generated</param>
public abstract partial record Response(string Number, string Service, string Context, string? ConversationId) : IMessage
Expand Down
2 changes: 1 addition & 1 deletion src/WhatsApp/TemplateResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/// The template is identified by its name and code. The <see cref="SendCoreAsync"/> method handles the actual sending
/// of the template message.</remarks>
/// <param name="Number">The phone number of the recipient in international format.</param>
/// <param name="ServiceId">The identifier of the service handling the message.</param>
/// <param name="Service">The identifier of the service handling the message.</param>
/// <param name="Context">The unique identifier of the message to which the reaction is being sent.</param>
/// <param name="Name">The template name</param>
/// <param name="Code">The template lang code</param>
Expand Down
2 changes: 1 addition & 1 deletion src/WhatsApp/TextResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/// <remarks>This response type allows sending a text message with up to two optional buttons for user
/// interaction. If no buttons are provided, the response will consist of only the text message.</remarks>
/// <param name="Number">The phone number of the recipient in international format.</param>
/// <param name="ServiceId">The identifier of the service handling the message.</param>
/// <param name="Service">The identifier of the service handling the message.</param>
/// <param name="Context">The unique identifier of the message to which the reaction is being sent.</param>
/// <param name="Text">The text content of the response message.</param>
/// <param name="Button1">An optional button to include in the response for user interaction.</param>
Expand Down