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
24 changes: 23 additions & 1 deletion src/Umbraco.Core/Services/IWebHookService.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,40 @@
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Models;

namespace Umbraco.Cms.Core.Services;

public interface IWebHookService
{
/// <summary>
/// Creates a webhook.
/// </summary>
/// <param name="webhook"><see cref="Webhook" /> to create.</param>
Task<Webhook> CreateAsync(Webhook webhook);

/// <summary>
/// Updates a webhook.
/// </summary>
/// <param name="webhook"><see cref="Webhook" /> to update.</param>
Task UpdateAsync(Webhook webhook);

/// <summary>
/// Deletes a webhook.
/// </summary>
/// <param name="key">The unique key of the webhook.</param>
Task DeleteAsync(Guid key);

/// <summary>
/// Gets a webhook by its key.
/// </summary>
/// <param name="key">The unique key of the webhook.</param>
Task<Webhook?> GetAsync(Guid key);

/// <summary>
/// Gets all webhooks.
/// </summary>
Task<PagedModel<Webhook>> GetAllAsync(int skip, int take);

/// <summary>
/// Gets webhooks by event name.
/// </summary>
Task<IEnumerable<Webhook>> GetByEventNameAsync(string eventName);
}
8 changes: 7 additions & 1 deletion src/Umbraco.Core/Services/WebhookService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Persistence.Repositories;
using Umbraco.Cms.Core.Scoping;

Expand All @@ -15,6 +15,7 @@ public WebhookService(ICoreScopeProvider provider, IWebhookRepository webhookRep
_webhookRepository = webhookRepository;
}

/// <inheritdoc />
public async Task<Webhook> CreateAsync(Webhook webhook)
{
using ICoreScope scope = _provider.CreateCoreScope();
Expand All @@ -24,6 +25,7 @@ public async Task<Webhook> CreateAsync(Webhook webhook)
return created;
}

/// <inheritdoc />
public async Task UpdateAsync(Webhook webhook)
{
using ICoreScope scope = _provider.CreateCoreScope();
Expand All @@ -45,6 +47,7 @@ public async Task UpdateAsync(Webhook webhook)
scope.Complete();
}

/// <inheritdoc />
public async Task DeleteAsync(Guid key)
{
using ICoreScope scope = _provider.CreateCoreScope();
Expand All @@ -57,6 +60,7 @@ public async Task DeleteAsync(Guid key)
scope.Complete();
}

/// <inheritdoc />
public async Task<Webhook?> GetAsync(Guid key)
{
using ICoreScope scope = _provider.CreateCoreScope();
Expand All @@ -65,6 +69,7 @@ public async Task DeleteAsync(Guid key)
return webhook;
}

/// <inheritdoc />
public async Task<PagedModel<Webhook>> GetAllAsync(int skip, int take)
{
using ICoreScope scope = _provider.CreateCoreScope();
Expand All @@ -74,6 +79,7 @@ public async Task<PagedModel<Webhook>> GetAllAsync(int skip, int take)
return webhooks;
}

/// <inheritdoc />
public async Task<IEnumerable<Webhook>> GetByEventNameAsync(string eventName)
{
using ICoreScope scope = _provider.CreateCoreScope();
Expand Down