diff --git a/Source/StrongGrid.IntegrationTests/Tests/WebhookSettings.cs b/Source/StrongGrid.IntegrationTests/Tests/WebhookSettings.cs index c7608532..d826f613 100644 --- a/Source/StrongGrid.IntegrationTests/Tests/WebhookSettings.cs +++ b/Source/StrongGrid.IntegrationTests/Tests/WebhookSettings.cs @@ -14,11 +14,15 @@ public async Task RunAsync(IBaseClient client, TextWriter log, CancellationToken // GET THE EVENT SETTINGS var eventWebhookSettings = await client.WebhookSettings.GetEventWebhookSettingsAsync(null, cancellationToken).ConfigureAwait(false); - await log.WriteLineAsync("The event webhooks settings have been retrieved.").ConfigureAwait(false); + await log.WriteLineAsync("The event webhook settings have been retrieved.").ConfigureAwait(false); // GET THE INBOUND PARSE SETTINGS var inboundParseWebhookSettings = await client.WebhookSettings.GetAllInboundParseWebhookSettingsAsync(null, cancellationToken).ConfigureAwait(false); - await log.WriteLineAsync("The inbound parse webhooks settings have been retrieved.").ConfigureAwait(false); + await log.WriteLineAsync("The inbound parse webhook settings have been retrieved.").ConfigureAwait(false); + + // GET THE SIGNED EVENTS PUBLIC KEY + var publicKey = await client.WebhookSettings.GetSignedEventsPublicKeyAsync(cancellationToken).ConfigureAwait(false); + await log.WriteLineAsync($"The signed events public key is: {publicKey}").ConfigureAwait(false); } } } diff --git a/Source/StrongGrid/Resources/IWebhookSettings.cs b/Source/StrongGrid/Resources/IWebhookSettings.cs index c0d6f176..eba36027 100644 --- a/Source/StrongGrid/Resources/IWebhookSettings.cs +++ b/Source/StrongGrid/Resources/IWebhookSettings.cs @@ -133,5 +133,14 @@ Task UpdateEventWebhookSettingsAsync( /// The async task. /// Task DeleteInboundParseWebhookSettingsAsync(string hostname, string onBehalfOf = null, CancellationToken cancellationToken = default); + + /// + /// Get the signed events public key. + /// + /// The cancellation token. + /// + /// The public key. + /// + Task GetSignedEventsPublicKeyAsync(CancellationToken cancellationToken = default); } } diff --git a/Source/StrongGrid/Resources/WebhookSettings.cs b/Source/StrongGrid/Resources/WebhookSettings.cs index 999b6382..fddf821e 100644 --- a/Source/StrongGrid/Resources/WebhookSettings.cs +++ b/Source/StrongGrid/Resources/WebhookSettings.cs @@ -234,6 +234,21 @@ public Task DeleteInboundParseWebhookSettingsAsync(string hostname, string onBeh .AsMessage(); } + /// + /// Get the signed event webhook public key. + /// + /// The cancellation token. + /// + /// The public key. + /// + public Task GetSignedEventWebhookPublicKeyAsync(CancellationToken cancellationToken = default) + { + return _client + .GetAsync($"{_eventWebhookEndpoint}/settings/signed") + .WithCancellationToken(cancellationToken) + .AsSendGridObject("public_key"); + } + private static JObject CreateJObject(string hostname, Parameter url, Parameter spamCheck, Parameter sendRaw) { var result = new JObject