diff --git a/src/modules/Elsa.Telnyx/Activities/AnswerCall.cs b/src/modules/Elsa.Telnyx/Activities/AnswerCall.cs index aedfa01d1..be116ff7c 100644 --- a/src/modules/Elsa.Telnyx/Activities/AnswerCall.cs +++ b/src/modules/Elsa.Telnyx/Activities/AnswerCall.cs @@ -92,6 +92,7 @@ public abstract class AnswerCallBase : Activity, IBookmarks /// /// The call control ID to answer. Leave blank when the workflow is driven by an incoming call and you wish to pick up that one. /// + [Input(DisplayName = "Call Control ID", Description = "The call control ID of the call to answer.", Category = "Advanced")] public Input? CallControlId { get; set; } /// diff --git a/src/modules/Elsa.Telnyx/Events/TelnyxWebhookReceived.cs b/src/modules/Elsa.Telnyx/Events/TelnyxWebhookReceived.cs index df4feb3fd..7bc09274a 100644 --- a/src/modules/Elsa.Telnyx/Events/TelnyxWebhookReceived.cs +++ b/src/modules/Elsa.Telnyx/Events/TelnyxWebhookReceived.cs @@ -3,13 +3,22 @@ using Elsa.Telnyx.Models; namespace Elsa.Telnyx.Events; +/// +/// Triggered when a Telnyx webhook is received. +/// public class TelnyxWebhookReceived : INotification { + /// + /// Initializes a new instance of the class. + /// public TelnyxWebhookReceived(TelnyxWebhook webhook) { Webhook = webhook; } + /// + /// Gets the webhook. + /// public TelnyxWebhook Webhook { get; } } \ No newline at end of file diff --git a/src/modules/Elsa.Telnyx/Extensions/DependencyInjectionExtensions.cs b/src/modules/Elsa.Telnyx/Extensions/DependencyInjectionExtensions.cs index d2e7c51fc..fe99b9241 100644 --- a/src/modules/Elsa.Telnyx/Extensions/DependencyInjectionExtensions.cs +++ b/src/modules/Elsa.Telnyx/Extensions/DependencyInjectionExtensions.cs @@ -30,6 +30,7 @@ public static class DependencyInjectionExtensions Action? configureHttpClientBuilder = default) { // Telnyx options. + configure ??= options => options.ApiUrl = new Uri("https://api.telnyx.com"); services.Configure(configure); // Services. diff --git a/src/modules/Elsa.Telnyx/Extensions/EndpointsExtensions.cs b/src/modules/Elsa.Telnyx/Extensions/EndpointsExtensions.cs index 4d329bade..2d50ea05d 100644 --- a/src/modules/Elsa.Telnyx/Extensions/EndpointsExtensions.cs +++ b/src/modules/Elsa.Telnyx/Extensions/EndpointsExtensions.cs @@ -1,4 +1,5 @@ using Elsa.Telnyx.Contracts; +using JetBrains.Annotations; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Routing; @@ -10,6 +11,7 @@ namespace Elsa.Extensions; /// /// Provides extensions on /// +[PublicAPI] public static class EndpointsExtensions { /// diff --git a/src/modules/Elsa.Telnyx/Handlers/TriggerBridgeCallActivities.cs b/src/modules/Elsa.Telnyx/Handlers/TriggerBridgeCallActivities.cs index a2f97e0cc..fa70d46d1 100644 --- a/src/modules/Elsa.Telnyx/Handlers/TriggerBridgeCallActivities.cs +++ b/src/modules/Elsa.Telnyx/Handlers/TriggerBridgeCallActivities.cs @@ -8,6 +8,7 @@ using Elsa.Telnyx.Payloads.Abstract; using Elsa.Telnyx.Payloads.Call; using Elsa.Workflows.Core.Helpers; using Elsa.Workflows.Runtime.Contracts; +using JetBrains.Annotations; using Microsoft.Extensions.Logging; namespace Elsa.Telnyx.Handlers; @@ -15,6 +16,7 @@ namespace Elsa.Telnyx.Handlers; /// /// Triggers all workflows starting with or blocked on a activity. /// +[PublicAPI] internal class TriggerBridgeCallActivities : INotificationHandler { private readonly IWorkflowRuntime _workflowRuntime; @@ -34,7 +36,7 @@ internal class TriggerBridgeCallActivities : INotificationHandler(); var input = new Dictionary().AddInput(callBridgedPayload); var callBridgedBookmarkPayload = new CallBridgedBookmarkPayload(callBridgedPayload.CallControlId); diff --git a/src/modules/Elsa.Telnyx/Handlers/TriggerIncomingCallActivities.cs b/src/modules/Elsa.Telnyx/Handlers/TriggerIncomingCallActivities.cs index eb2780493..6e81b36d5 100644 --- a/src/modules/Elsa.Telnyx/Handlers/TriggerIncomingCallActivities.cs +++ b/src/modules/Elsa.Telnyx/Handlers/TriggerIncomingCallActivities.cs @@ -8,6 +8,7 @@ using Elsa.Telnyx.Payloads.Abstract; using Elsa.Telnyx.Payloads.Call; using Elsa.Workflows.Core.Helpers; using Elsa.Workflows.Runtime.Contracts; +using JetBrains.Annotations; using Microsoft.Extensions.Logging; namespace Elsa.Telnyx.Handlers; @@ -15,6 +16,7 @@ namespace Elsa.Telnyx.Handlers; /// /// Triggers all workflows starting with or blocked on a activity. /// +[PublicAPI] internal class TriggerIncomingCallActivities : INotificationHandler { private readonly IWorkflowRuntime _workflowRuntime; @@ -37,7 +39,7 @@ internal class TriggerIncomingCallActivities : INotificationHandler(); var input = new Dictionary().AddInput(webhook); diff --git a/src/modules/Elsa.Telnyx/Handlers/TriggerWebhookActivities.cs b/src/modules/Elsa.Telnyx/Handlers/TriggerWebhookActivities.cs index d36ccb42c..b75209f4d 100644 --- a/src/modules/Elsa.Telnyx/Handlers/TriggerWebhookActivities.cs +++ b/src/modules/Elsa.Telnyx/Handlers/TriggerWebhookActivities.cs @@ -8,6 +8,7 @@ using Elsa.Telnyx.Events; using Elsa.Telnyx.Extensions; using Elsa.Telnyx.Payloads.Abstract; using Elsa.Workflows.Runtime.Contracts; +using JetBrains.Annotations; using Microsoft.Extensions.Logging; namespace Elsa.Telnyx.Handlers; @@ -15,6 +16,7 @@ namespace Elsa.Telnyx.Handlers; /// /// Triggers all workflows starting with or blocked on a activity. /// +[PublicAPI] internal class TriggerWebhookActivities : INotificationHandler { private readonly IWorkflowRuntime _workflowRuntime; diff --git a/src/modules/Elsa.Telnyx/Handlers/TriggerWebhookDrivenActivities.cs b/src/modules/Elsa.Telnyx/Handlers/TriggerWebhookDrivenActivities.cs index 39dc80d59..2c85fccb8 100644 --- a/src/modules/Elsa.Telnyx/Handlers/TriggerWebhookDrivenActivities.cs +++ b/src/modules/Elsa.Telnyx/Handlers/TriggerWebhookDrivenActivities.cs @@ -8,12 +8,14 @@ using Elsa.Telnyx.Payloads.Abstract; using Elsa.Workflows.Core.Contracts; using Elsa.Workflows.Core.Models; using Elsa.Workflows.Runtime.Contracts; +using JetBrains.Annotations; namespace Elsa.Telnyx.Handlers; /// /// Resumes all workflows blocked on activities that are waiting for a given webhook. /// +[PublicAPI] internal class TriggerWebhookDrivenActivities : INotificationHandler { private readonly IWorkflowRuntime _workflowRuntime; diff --git a/src/modules/Elsa.Telnyx/Helpers/PayloadSerializer.cs b/src/modules/Elsa.Telnyx/Helpers/PayloadSerializer.cs index 87226f2f1..441f03d8d 100644 --- a/src/modules/Elsa.Telnyx/Helpers/PayloadSerializer.cs +++ b/src/modules/Elsa.Telnyx/Helpers/PayloadSerializer.cs @@ -8,7 +8,7 @@ internal static class PayloadSerializer { public static Payload Deserialize(string eventType, JsonElement dataModel, JsonSerializerOptions? options = null) { - var payloadType = WebhookPayloadTypes.PayloadTypeDictionary.ContainsKey(eventType) ? WebhookPayloadTypes.PayloadTypeDictionary[eventType] : typeof(UnsupportedPayload); + var payloadType = WebhookPayloadTypes.PayloadTypeDictionary.TryGetValue(eventType, out var value) ? value : typeof(UnsupportedPayload); return (Payload)dataModel.Deserialize(payloadType, options)!; } } \ No newline at end of file diff --git a/src/modules/Elsa.Telnyx/Services/WebhookHandler.cs b/src/modules/Elsa.Telnyx/Services/WebhookHandler.cs index c2b2f249a..15c7a4b5d 100644 --- a/src/modules/Elsa.Telnyx/Services/WebhookHandler.cs +++ b/src/modules/Elsa.Telnyx/Services/WebhookHandler.cs @@ -16,7 +16,7 @@ namespace Elsa.Telnyx.Services; internal class WebhookHandler : IWebhookHandler { private static readonly JsonSerializerOptions SerializerSettings; - private readonly INotificationSender _mediator; + private readonly INotificationSender _notificationSender; private readonly ILogger _logger; static WebhookHandler() @@ -24,9 +24,9 @@ internal class WebhookHandler : IWebhookHandler SerializerSettings = CreateSerializerSettings(); } - public WebhookHandler(INotificationSender mediator, ILogger logger) + public WebhookHandler(INotificationSender notificationSender, ILogger logger) { - _mediator = mediator; + _notificationSender = notificationSender; _logger = logger; } @@ -39,7 +39,7 @@ internal class WebhookHandler : IWebhookHandler using var loggingScope = _logger.BeginScope(new Dictionary { ["CorrelationId"] = correlationId }); _logger.LogDebug("Telnyx webhook payload received: {@Webhook}", webhook); - await _mediator.SendAsync(new TelnyxWebhookReceived(webhook), NotificationStrategy.Background, cancellationToken); + await _notificationSender.SendAsync(new TelnyxWebhookReceived(webhook), NotificationStrategy.Background, cancellationToken); } private static async Task ReadRequestBodyAsync(HttpContext httpContext)