From f2cbf2e182f8caa92b46df288588e73ff6b9c4ec Mon Sep 17 00:00:00 2001 From: Artem Riabushenko Date: Wed, 28 Jan 2026 20:26:45 +0200 Subject: [PATCH 1/4] Added test project, Name changes, Docs update, error handling update --- .gitignore | 1 + ClickUp.sln | 15 ++++++- ClickUp/Actions/CustomFieldActions.cs | 2 +- ClickUp/Actions/FolderActions.cs | 2 +- ClickUp/Actions/GoalActions.cs | 2 +- ClickUp/Actions/SpaceActions.cs | 2 +- ClickUp/Actions/TagActions.cs | 2 +- ClickUp/Actions/TaskActions.cs | 2 +- ClickUp/Actions/TeamActions.cs | 2 +- ClickUp/Actions/UserGroupActions.cs | 2 +- ClickUp/Api/ClickUpClient.cs | 31 +++++++++---- ClickUp/Apps.ClickUp.csproj | 2 +- ClickUp/Connections/ConnectionDefinition.cs | 2 +- README.md | 14 +++--- Tests.ClickUp/Base/FileManager.cs | 48 +++++++++++++++++++++ Tests.ClickUp/Base/TestBase.cs | 32 ++++++++++++++ Tests.ClickUp/DataHandlerTests.cs | 13 ++++++ Tests.ClickUp/GlobalUsings.cs | 1 + Tests.ClickUp/TestFiles/Input/test.txt | 1 + Tests.ClickUp/Tests.ClickUp.csproj | 37 ++++++++++++++++ Tests.ClickUp/ValidatorTests.cs | 31 +++++++++++++ Tests.ClickUp/appsettings.json.example | 6 +++ 22 files changed, 223 insertions(+), 27 deletions(-) create mode 100644 Tests.ClickUp/Base/FileManager.cs create mode 100644 Tests.ClickUp/Base/TestBase.cs create mode 100644 Tests.ClickUp/DataHandlerTests.cs create mode 100644 Tests.ClickUp/GlobalUsings.cs create mode 100644 Tests.ClickUp/TestFiles/Input/test.txt create mode 100644 Tests.ClickUp/Tests.ClickUp.csproj create mode 100644 Tests.ClickUp/ValidatorTests.cs create mode 100644 Tests.ClickUp/appsettings.json.example diff --git a/.gitignore b/.gitignore index c2f1c8d..f4a5a85 100644 --- a/.gitignore +++ b/.gitignore @@ -354,3 +354,4 @@ healthchecksdb *.DS_Store *.dmg *.env +/Tests.ClickUp/appsettings.json diff --git a/ClickUp.sln b/ClickUp.sln index a6bca35..15ea689 100644 --- a/ClickUp.sln +++ b/ClickUp.sln @@ -1,10 +1,17 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.5.33414.496 +# Visual Studio Version 18 +VisualStudioVersion = 18.3.11304.161 d18.3 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Apps.ClickUp", "ClickUp\Apps.ClickUp.csproj", "{1EA52DCB-451F-4722-9949-635F21C3B086}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests.ClickUp", "Tests.ClickUp\Tests.ClickUp.csproj", "{ABE6BE7D-96C0-6036-4532-550F2AA40CE1}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{E1008505-4655-43D9-970A-D9A118CBB131}" + ProjectSection(SolutionItems) = preProject + README.md = README.md + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -15,6 +22,10 @@ Global {1EA52DCB-451F-4722-9949-635F21C3B086}.Debug|Any CPU.Build.0 = Debug|Any CPU {1EA52DCB-451F-4722-9949-635F21C3B086}.Release|Any CPU.ActiveCfg = Release|Any CPU {1EA52DCB-451F-4722-9949-635F21C3B086}.Release|Any CPU.Build.0 = Release|Any CPU + {ABE6BE7D-96C0-6036-4532-550F2AA40CE1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {ABE6BE7D-96C0-6036-4532-550F2AA40CE1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {ABE6BE7D-96C0-6036-4532-550F2AA40CE1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {ABE6BE7D-96C0-6036-4532-550F2AA40CE1}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/ClickUp/Actions/CustomFieldActions.cs b/ClickUp/Actions/CustomFieldActions.cs index 055a868..ad62fa0 100644 --- a/ClickUp/Actions/CustomFieldActions.cs +++ b/ClickUp/Actions/CustomFieldActions.cs @@ -21,7 +21,7 @@ public CustomFieldActions(InvocationContext invocationContext) : base(invocation { } - [Action("List custom fields", Description = "List all accessible custom fields")] + [Action("Search custom fields", Description = "List all accessible custom fields")] public Task ListCustomFields([ActionParameter] ListRequest list) { var endpoint = $"{ApiEndpoints.Lists}/{list.ListId}{ApiEndpoints.CustomFields}"; diff --git a/ClickUp/Actions/FolderActions.cs b/ClickUp/Actions/FolderActions.cs index 4881e0c..dc7bc99 100644 --- a/ClickUp/Actions/FolderActions.cs +++ b/ClickUp/Actions/FolderActions.cs @@ -22,7 +22,7 @@ public FolderActions(InvocationContext invocationContext) : base(invocationConte { } - [Action("Get folders", Description = "Get all folders given a specific space")] + [Action("Search folders", Description = "Get all folders given a specific space")] public Task GetFolders( [ActionParameter] SpaceRequest space, [ActionParameter] ListQuery query) diff --git a/ClickUp/Actions/GoalActions.cs b/ClickUp/Actions/GoalActions.cs index ada7273..235b802 100644 --- a/ClickUp/Actions/GoalActions.cs +++ b/ClickUp/Actions/GoalActions.cs @@ -21,7 +21,7 @@ public GoalActions(InvocationContext invocationContext) : base(invocationContext { } - [Action("Get goals", Description = "Get all goals")] + [Action("Search goals", Description = "Get all goals")] public Task GetGoals( [ActionParameter] TeamRequest team, [ActionParameter] ListGoalsQuery query) diff --git a/ClickUp/Actions/SpaceActions.cs b/ClickUp/Actions/SpaceActions.cs index 0a15477..9f3208f 100644 --- a/ClickUp/Actions/SpaceActions.cs +++ b/ClickUp/Actions/SpaceActions.cs @@ -22,7 +22,7 @@ public SpaceActions(InvocationContext invocationContext) : base(invocationContex { } - [Action("Get spaces", Description = "Get all spaces given a specific team")] + [Action("Search spaces", Description = "Get all spaces given a specific team")] public Task GetSpaces( [ActionParameter] TeamRequest team, [ActionParameter] ListQuery query) diff --git a/ClickUp/Actions/TagActions.cs b/ClickUp/Actions/TagActions.cs index bcae248..4da95cb 100644 --- a/ClickUp/Actions/TagActions.cs +++ b/ClickUp/Actions/TagActions.cs @@ -20,7 +20,7 @@ public TagActions(InvocationContext invocationContext) : base(invocationContext) { } - [Action("Get tags", Description = "Get all space tags")] + [Action("Search tags", Description = "Get all space tags")] public Task GetTags([ActionParameter] SpaceRequest space) { var endpoint = $"{ApiEndpoints.Spaces}/{space.SpaceId}{ApiEndpoints.Tags}"; diff --git a/ClickUp/Actions/TaskActions.cs b/ClickUp/Actions/TaskActions.cs index 7a791f1..d68323d 100644 --- a/ClickUp/Actions/TaskActions.cs +++ b/ClickUp/Actions/TaskActions.cs @@ -26,7 +26,7 @@ public TaskActions(InvocationContext invocationContext) : base(invocationContext { } - [Action("Get tasks", Description = "Get all tasks given a specific list")] + [Action("Search tasks", Description = "Get all tasks given a specific list")] public Task GetTasksFromList([ActionParameter] ListRequest list) { var endpoint = $"{ApiEndpoints.Lists}/{list.ListId}{ApiEndpoints.Tasks}"; diff --git a/ClickUp/Actions/TeamActions.cs b/ClickUp/Actions/TeamActions.cs index 2326001..548c0b9 100644 --- a/ClickUp/Actions/TeamActions.cs +++ b/ClickUp/Actions/TeamActions.cs @@ -15,7 +15,7 @@ public TeamActions(InvocationContext invocationContext) : base(invocationContext { } - [Action("Get teams", Description = "Get all teams for this user connection")] + [Action("Search teams", Description = "Get all teams for this user connection")] public Task GetTeams() { var request = new ClickUpRequest(ApiEndpoints.Teams, Method.Get, Creds); diff --git a/ClickUp/Actions/UserGroupActions.cs b/ClickUp/Actions/UserGroupActions.cs index b11ff85..8759985 100644 --- a/ClickUp/Actions/UserGroupActions.cs +++ b/ClickUp/Actions/UserGroupActions.cs @@ -21,7 +21,7 @@ public UserGroupActions(InvocationContext invocationContext) : base(invocationCo { } - [Action("Get user groups", Description = "Get all user groups")] + [Action("Search user groups", Description = "Get all user groups")] public Task GetGroups([ActionParameter] ListGroupsQuery query) { var endpoint = ApiEndpoints.Groups; diff --git a/ClickUp/Api/ClickUpClient.cs b/ClickUp/Api/ClickUpClient.cs index da6f675..325bb89 100644 --- a/ClickUp/Api/ClickUpClient.cs +++ b/ClickUp/Api/ClickUpClient.cs @@ -1,5 +1,6 @@ using Apps.ClickUp.Constants; using Apps.ClickUp.Models.Response; +using Blackbird.Applications.Sdk.Common.Exceptions; using Blackbird.Applications.Sdk.Utils.Extensions.String; using Blackbird.Applications.Sdk.Utils.RestSharp; using Newtonsoft.Json; @@ -15,19 +16,33 @@ public ClickUpClient() : base(new RestClientOptions() }) { } - - public new async Task ExecuteWithErrorHandling(RestRequest request) + + public async Task ExecuteWithErrorHandling(RestRequest request) + { + string content = (await ExecuteWithErrorHandling(request)).Content; + T val = JsonConvert.DeserializeObject(content); + if (val == null) + { + throw new Exception($"Could not parse {content} to {typeof(T)}"); + } + + return val; + } + + public async Task ExecuteWithErrorHandling(RestRequest request) { - var response = await ExecuteWithErrorHandling(request); - var json = response.Content!; + RestResponse restResponse = await ExecuteAsync(request); + if (!restResponse.IsSuccessStatusCode) + { + throw ConfigureErrorException(restResponse); + } - return JsonConvert.DeserializeObject(json, JsonConfig.Settings) ?? - throw new($"Could not parse {json} to {typeof(T)}"); + return restResponse; } protected override Exception ConfigureErrorException(RestResponse response) { - var error = JsonConvert.DeserializeObject(response.Content); - return new(error.Err); + var error = JsonConvert.DeserializeObject(response.Content); + throw new PluginApplicationException($"{error}"); } } \ No newline at end of file diff --git a/ClickUp/Apps.ClickUp.csproj b/ClickUp/Apps.ClickUp.csproj index 5649715..8deee14 100644 --- a/ClickUp/Apps.ClickUp.csproj +++ b/ClickUp/Apps.ClickUp.csproj @@ -5,7 +5,7 @@ enable ClickUp Customizable workplace productivity platform - 1.0.7 + 1.0.8 Apps.ClickUp diff --git a/ClickUp/Connections/ConnectionDefinition.cs b/ClickUp/Connections/ConnectionDefinition.cs index 3931ccc..90ca4f9 100644 --- a/ClickUp/Connections/ConnectionDefinition.cs +++ b/ClickUp/Connections/ConnectionDefinition.cs @@ -15,7 +15,7 @@ public class ConnectionDefinition : IConnectionDefinition ConnectionUsage = ConnectionUsage.Actions, ConnectionProperties = new List() { - new(CredsNames.Token) { DisplayName = "Token" } + new(CredsNames.Token) { DisplayName = "Token", Sensitive=true } } } }; diff --git a/README.md b/README.md index 1f945e0..6a85766 100644 --- a/README.md +++ b/README.md @@ -27,12 +27,12 @@ ClickUp project management software that allows you to plan, track and collabora ### Folders -- **Get folders** returns all folders of a chosen `space`. +- **Search folders** returns all folders of a chosen `space`. - **Get/create/delete folder**. ### Goals -- **Get goals** returns all goals of specified `team`. +- **Search goals** returns all goals of specified `team`. - **Get/create/delete goal**. - **Create key result** adds a `target` to a goal. @@ -46,26 +46,26 @@ ClickUp project management software that allows you to plan, track and collabora ### Spaces -- **Get spaces** returns all spaces of specified `team`. +- **Search spaces** returns all spaces of specified `team`. - **Get/create/update/delete space** ### Tags -- **List tags** returns all tags of specified `space`. +- **Search tags** returns all tags of specified `space`. - **Create/delete tag**. ### Tasks -- **Get tasks** returns all tasks of specified `list`. +- **Search tasks** returns all tasks of specified `list`. - **Get/create/delete task**. ### Teams - Workspaces -- **Get teams** returns all teams available to the authenticated user. +- **Search teams** returns all teams available to the authenticated user. ### Teams - User Groups -- **Get user groups** returns all user groups in the workspace. +- **Search user groups** returns all user groups in the workspace. - **Create/delete user group**. ## Events diff --git a/Tests.ClickUp/Base/FileManager.cs b/Tests.ClickUp/Base/FileManager.cs new file mode 100644 index 0000000..6851d37 --- /dev/null +++ b/Tests.ClickUp/Base/FileManager.cs @@ -0,0 +1,48 @@ +using Blackbird.Applications.Sdk.Common.Files; +using Blackbird.Applications.SDK.Extensions.FileManagement.Interfaces; + +namespace Tests.ClickUp.Base; + +public class FileManager : IFileManagementClient +{ + private readonly string inputFolder; + private readonly string outputFolder; + + public FileManager() + { + var baseDirectory = AppDomain.CurrentDomain.BaseDirectory; + var projectDirectory = Directory.GetParent(baseDirectory).Parent.Parent.Parent.FullName; + + + var testFilesPath = Path.Combine(projectDirectory, "TestFiles"); + inputFolder = Path.Combine(testFilesPath, "Input"); + outputFolder = Path.Combine(testFilesPath, "Output"); + + Directory.CreateDirectory(inputFolder); + Directory.CreateDirectory(outputFolder); + } + + + public Task DownloadAsync(FileReference reference) + { + var path = Path.Combine(inputFolder, reference.Name); + Assert.IsTrue(File.Exists(path), $"File not found at: {path}"); + var bytes = File.ReadAllBytes(path); + + var stream = new MemoryStream(bytes); + return Task.FromResult((Stream)stream); + } + + public Task UploadAsync(Stream stream, string contentType, string fileName) + { + var path = Path.Combine(outputFolder, fileName); + new FileInfo(path).Directory.Create(); + using (var fileStream = File.Create(path)) + { + stream.CopyTo(fileStream); + } + + return Task.FromResult(new FileReference() { Name = fileName, ContentType = contentType }); + } +} + diff --git a/Tests.ClickUp/Base/TestBase.cs b/Tests.ClickUp/Base/TestBase.cs new file mode 100644 index 0000000..8a43b5f --- /dev/null +++ b/Tests.ClickUp/Base/TestBase.cs @@ -0,0 +1,32 @@ +using Blackbird.Applications.Sdk.Common.Authentication; +using Blackbird.Applications.Sdk.Common.Invocation; +using Microsoft.Extensions.Configuration; + +namespace Tests.ClickUp.Base; +public class TestBase +{ + public IEnumerable Creds { get; set; } + + public InvocationContext InvocationContext { get; set; } + + public FileManager FileManager { get; set; } + + public TestBase() + { + var config = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build(); + Creds = config.GetSection("ConnectionDefinition").GetChildren() + .Select(x => new AuthenticationCredentialsProvider(x.Key, x.Value)).ToList(); + + + var relativePath = config.GetSection("TestFolder").Value; + var projectDirectory = Directory.GetParent(AppDomain.CurrentDomain.BaseDirectory).Parent.Parent.Parent.FullName; + var folderLocation = Path.Combine(projectDirectory, relativePath); + + InvocationContext = new InvocationContext + { + AuthenticationCredentialsProviders = Creds, + }; + + FileManager = new FileManager(); + } +} diff --git a/Tests.ClickUp/DataHandlerTests.cs b/Tests.ClickUp/DataHandlerTests.cs new file mode 100644 index 0000000..bae2333 --- /dev/null +++ b/Tests.ClickUp/DataHandlerTests.cs @@ -0,0 +1,13 @@ +using Tests.ClickUp.Base; + +namespace Tests.ClickUp; + +[TestClass] +public class DataHandlerTests : TestBase +{ + [TestMethod] + public async Task _works() + { + + } +} diff --git a/Tests.ClickUp/GlobalUsings.cs b/Tests.ClickUp/GlobalUsings.cs new file mode 100644 index 0000000..ab67c7e --- /dev/null +++ b/Tests.ClickUp/GlobalUsings.cs @@ -0,0 +1 @@ +global using Microsoft.VisualStudio.TestTools.UnitTesting; \ No newline at end of file diff --git a/Tests.ClickUp/TestFiles/Input/test.txt b/Tests.ClickUp/TestFiles/Input/test.txt new file mode 100644 index 0000000..6769dd6 --- /dev/null +++ b/Tests.ClickUp/TestFiles/Input/test.txt @@ -0,0 +1 @@ +Hello world! \ No newline at end of file diff --git a/Tests.ClickUp/Tests.ClickUp.csproj b/Tests.ClickUp/Tests.ClickUp.csproj new file mode 100644 index 0000000..5243457 --- /dev/null +++ b/Tests.ClickUp/Tests.ClickUp.csproj @@ -0,0 +1,37 @@ + + + + net8.0 + enable + enable + + false + true + + + + + + + + + + + + + + + + + Always + + + Always + + + + + + + + diff --git a/Tests.ClickUp/ValidatorTests.cs b/Tests.ClickUp/ValidatorTests.cs new file mode 100644 index 0000000..ec70acd --- /dev/null +++ b/Tests.ClickUp/ValidatorTests.cs @@ -0,0 +1,31 @@ +using Apps.ClickUp.Connections; +using Blackbird.Applications.Sdk.Common.Authentication; +using Tests.ClickUp.Base; + +namespace Tests.ClickUp; + +[TestClass] +public class ConnectionValidatorTests : TestBase +{ + [TestMethod] + public async Task ValidateConnection_ValidData_ShouldBeSuccessful() + { + var validator = new ConnectionValidator(); + + var result = await validator.ValidateConnection(Creds, CancellationToken.None); + Console.WriteLine(result.Message); + Assert.IsTrue(result.IsValid); + } + + [TestMethod] + public async Task ValidateConnection_InvalidData_ShouldFail() + { + var validator = new ConnectionValidator(); + var newCredentials = Creds + .Select(x => new AuthenticationCredentialsProvider(x.KeyName, x.Value + "_incorrect")); + + var result = await validator.ValidateConnection(newCredentials, CancellationToken.None); + Console.WriteLine(result.Message); + Assert.IsFalse(result.IsValid); + } +} \ No newline at end of file diff --git a/Tests.ClickUp/appsettings.json.example b/Tests.ClickUp/appsettings.json.example new file mode 100644 index 0000000..fc43ad3 --- /dev/null +++ b/Tests.ClickUp/appsettings.json.example @@ -0,0 +1,6 @@ +{ + "ConnectionDefinition": { + "token": "" + }, + "TestFolder": "TestFiles" +} \ No newline at end of file From 247809e1580066071ce2f13fb6f91d5720507997 Mon Sep 17 00:00:00 2001 From: Artem Riabushenko Date: Thu, 29 Jan 2026 14:20:06 +0200 Subject: [PATCH 2/4] Reworked webhooks with extended filters for input --- .../Webhooks/Handlers/BaseWebhookHandler.cs | 51 ++++++++++++++++--- .../Handlers/Folder/FolderCreatedHandler.cs | 2 +- .../Handlers/Folder/FolderDeletedHandler.cs | 2 +- .../Handlers/Folder/FolderUpdatedHandler.cs | 2 +- .../Handlers/Goal/GoalCreatedHandler.cs | 2 +- .../Handlers/Goal/GoalDeletedHandler.cs | 2 +- .../Handlers/Goal/GoalUpdatedHandler.cs | 2 +- .../KeyResult/KeyResultCreatedHandler.cs | 2 +- .../KeyResult/KeyResultDeletedHandler.cs | 2 +- .../KeyResult/KeyResultUpdatedHandler.cs | 2 +- .../Handlers/List/ListCreatedHandler.cs | 2 +- .../Handlers/List/ListDeletedHandler.cs | 2 +- .../Handlers/List/ListUpdatedHandler.cs | 2 +- .../Handlers/Space/SpaceCreatedHandler.cs | 2 +- .../Handlers/Space/SpaceDeletedHandler.cs | 2 +- .../Handlers/Space/SpaceUpdatedHandler.cs | 2 +- .../DataHandlers/FolderWebhookDataHandler.cs | 15 ++++++ .../DataHandlers/ListWebhookDataHandler.cs | 15 ++++++ .../DataHandlers/SpaceWebhookDataHandler.cs | 15 ++++++ .../DataHandlers/TaskWebhookDataHandler.cs | 16 ++++++ .../Tasks/TaskAssigneeUpdatedHandler.cs | 2 +- .../Tasks/TaskCommentPostedHandler.cs | 2 +- .../Tasks/TaskCommentUpdatedHandler.cs | 2 +- .../Handlers/Tasks/TaskCreatedHandler.cs | 2 +- .../Handlers/Tasks/TaskDeletedHandler.cs | 2 +- .../Tasks/TaskDueDateUpdatedHandler.cs | 2 +- .../Handlers/Tasks/TaskMovedHandler.cs | 2 +- .../Tasks/TaskPriorityUpdatedHandler.cs | 2 +- .../Tasks/TaskStatusUpdatedHandler.cs | 2 +- .../Handlers/Tasks/TaskTagUpdatedHandler.cs | 2 +- .../Tasks/TaskTimeEstimateUpdatedHandler.cs | 2 +- .../Tasks/TaskTimeTrackedUpdatedHandler.cs | 2 +- .../Handlers/Tasks/TaskUpdatedHandler.cs | 2 +- .../Webhooks/Handlers/WebhookScopeRequest.cs | 30 +++++++++++ .../Models/Request/AddWebhookRequest.cs | 23 +++++++-- Tests.ClickUp/TestFiles/Input/test.txt | 1 - Tests.ClickUp/Tests.ClickUp.csproj | 1 + 37 files changed, 185 insertions(+), 38 deletions(-) create mode 100644 ClickUp/Webhooks/Handlers/Tasks/DataHandlers/FolderWebhookDataHandler.cs create mode 100644 ClickUp/Webhooks/Handlers/Tasks/DataHandlers/ListWebhookDataHandler.cs create mode 100644 ClickUp/Webhooks/Handlers/Tasks/DataHandlers/SpaceWebhookDataHandler.cs create mode 100644 ClickUp/Webhooks/Handlers/Tasks/DataHandlers/TaskWebhookDataHandler.cs create mode 100644 ClickUp/Webhooks/Handlers/WebhookScopeRequest.cs delete mode 100644 Tests.ClickUp/TestFiles/Input/test.txt diff --git a/ClickUp/Webhooks/Handlers/BaseWebhookHandler.cs b/ClickUp/Webhooks/Handlers/BaseWebhookHandler.cs index 74a06fd..dfc3ae1 100644 --- a/ClickUp/Webhooks/Handlers/BaseWebhookHandler.cs +++ b/ClickUp/Webhooks/Handlers/BaseWebhookHandler.cs @@ -1,6 +1,5 @@ using Apps.ClickUp.Api; using Apps.ClickUp.Constants; -using Apps.ClickUp.Models.Request.Team; using Apps.ClickUp.Webhooks.Models.Payloads.Additional; using Apps.ClickUp.Webhooks.Models.Request; using Blackbird.Applications.Sdk.Common.Authentication; @@ -14,12 +13,14 @@ public abstract class BaseWebhookHandler : IWebhookEventHandler { protected abstract string EventType { get; } private string TeamId { get; } - + protected WebhookScopeRequest Scope { get; } + private ClickUpClient Client { get; } - public BaseWebhookHandler([WebhookParameter] TeamRequest input) + public BaseWebhookHandler([WebhookParameter] WebhookScopeRequest input) { TeamId = input.TeamId; + Scope = input; Client = new(); } @@ -31,6 +32,8 @@ public Task SubscribeAsync(IEnumerable creds, Events = new List { EventType } }; + ApplyScope(payload, Scope); + var endpoint = $"{ApiEndpoints.Teams}/{TeamId}{ApiEndpoints.Webhooks}"; var request = new ClickUpRequest(endpoint, Method.Post, creds) .WithJsonBody(payload, JsonConfig.Settings); @@ -43,13 +46,13 @@ public async Task UnsubscribeAsync(IEnumerable x.Endpoint == values["payloadUrl"]); - + if (currentHook == null) return; var endpoint = $"{ApiEndpoints.Webhooks}/{currentHook.Id}"; var request = new ClickUpRequest(endpoint, Method.Delete, creds); - + await Client.ExecuteWithErrorHandling(request); } @@ -57,7 +60,43 @@ private Task GetAllWebhooks(IEnumerable(request); } + + private static void ApplyScope(AddWebhookRequest payload, WebhookScopeRequest scope) + { + var taskId = Normalize(scope.TaskId); + if (!string.IsNullOrWhiteSpace(taskId)) + { + payload.TaskId = taskId; + return; + } + + var listId = TryParseLong(scope.ListId); + if (listId.HasValue) + { + payload.ListId = listId.Value; + return; + } + + var folderId = TryParseLong(scope.FolderId); + if (folderId.HasValue) + { + payload.FolderId = folderId.Value; + return; + } + + var spaceId = TryParseLong(scope.SpaceId); + if (spaceId.HasValue) + { + payload.SpaceId = spaceId.Value; + } + } + + private static long? TryParseLong(string? value) + => long.TryParse(value?.Trim(), out var v) ? v : null; + + private static string? Normalize(string? value) + => string.IsNullOrWhiteSpace(value) ? null : value.Trim(); } \ No newline at end of file diff --git a/ClickUp/Webhooks/Handlers/Folder/FolderCreatedHandler.cs b/ClickUp/Webhooks/Handlers/Folder/FolderCreatedHandler.cs index 6a4fb41..9896353 100644 --- a/ClickUp/Webhooks/Handlers/Folder/FolderCreatedHandler.cs +++ b/ClickUp/Webhooks/Handlers/Folder/FolderCreatedHandler.cs @@ -7,7 +7,7 @@ public class FolderCreatedHandler : BaseWebhookHandler { protected override string EventType => "folderCreated"; - public FolderCreatedHandler([WebhookParameter] TeamRequest team) : base(team) + public FolderCreatedHandler([WebhookParameter] WebhookScopeRequest team) : base(team) { } } \ No newline at end of file diff --git a/ClickUp/Webhooks/Handlers/Folder/FolderDeletedHandler.cs b/ClickUp/Webhooks/Handlers/Folder/FolderDeletedHandler.cs index 4520b87..810f84d 100644 --- a/ClickUp/Webhooks/Handlers/Folder/FolderDeletedHandler.cs +++ b/ClickUp/Webhooks/Handlers/Folder/FolderDeletedHandler.cs @@ -7,7 +7,7 @@ public class FolderDeletedHandler : BaseWebhookHandler { protected override string EventType => "folderDeleted"; - public FolderDeletedHandler([WebhookParameter] TeamRequest team) : base(team) + public FolderDeletedHandler([WebhookParameter] WebhookScopeRequest team) : base(team) { } } \ No newline at end of file diff --git a/ClickUp/Webhooks/Handlers/Folder/FolderUpdatedHandler.cs b/ClickUp/Webhooks/Handlers/Folder/FolderUpdatedHandler.cs index 8f3629b..378c336 100644 --- a/ClickUp/Webhooks/Handlers/Folder/FolderUpdatedHandler.cs +++ b/ClickUp/Webhooks/Handlers/Folder/FolderUpdatedHandler.cs @@ -7,7 +7,7 @@ public class FolderUpdatedHandler : BaseWebhookHandler { protected override string EventType => "folderUpdated"; - public FolderUpdatedHandler([WebhookParameter] TeamRequest team) : base(team) + public FolderUpdatedHandler([WebhookParameter] WebhookScopeRequest team) : base(team) { } } \ No newline at end of file diff --git a/ClickUp/Webhooks/Handlers/Goal/GoalCreatedHandler.cs b/ClickUp/Webhooks/Handlers/Goal/GoalCreatedHandler.cs index 42d1d44..6530bd9 100644 --- a/ClickUp/Webhooks/Handlers/Goal/GoalCreatedHandler.cs +++ b/ClickUp/Webhooks/Handlers/Goal/GoalCreatedHandler.cs @@ -7,7 +7,7 @@ public class GoalCreatedHandler : BaseWebhookHandler { protected override string EventType => "goalCreated"; - public GoalCreatedHandler([WebhookParameter] TeamRequest team) : base(team) + public GoalCreatedHandler([WebhookParameter] WebhookScopeRequest team) : base(team) { } } \ No newline at end of file diff --git a/ClickUp/Webhooks/Handlers/Goal/GoalDeletedHandler.cs b/ClickUp/Webhooks/Handlers/Goal/GoalDeletedHandler.cs index 8e38feb..67e1881 100644 --- a/ClickUp/Webhooks/Handlers/Goal/GoalDeletedHandler.cs +++ b/ClickUp/Webhooks/Handlers/Goal/GoalDeletedHandler.cs @@ -7,7 +7,7 @@ public class GoalDeletedHandler : BaseWebhookHandler { protected override string EventType => "goalDeleted"; - public GoalDeletedHandler([WebhookParameter] TeamRequest team) : base(team) + public GoalDeletedHandler([WebhookParameter] WebhookScopeRequest team) : base(team) { } } \ No newline at end of file diff --git a/ClickUp/Webhooks/Handlers/Goal/GoalUpdatedHandler.cs b/ClickUp/Webhooks/Handlers/Goal/GoalUpdatedHandler.cs index 92254a2..4b4d03d 100644 --- a/ClickUp/Webhooks/Handlers/Goal/GoalUpdatedHandler.cs +++ b/ClickUp/Webhooks/Handlers/Goal/GoalUpdatedHandler.cs @@ -7,7 +7,7 @@ public class GoalUpdatedHandler : BaseWebhookHandler { protected override string EventType => "goalUpdated"; - public GoalUpdatedHandler([WebhookParameter] TeamRequest team) : base(team) + public GoalUpdatedHandler([WebhookParameter] WebhookScopeRequest team) : base(team) { } } \ No newline at end of file diff --git a/ClickUp/Webhooks/Handlers/KeyResult/KeyResultCreatedHandler.cs b/ClickUp/Webhooks/Handlers/KeyResult/KeyResultCreatedHandler.cs index 30ba8f1..8ed69e9 100644 --- a/ClickUp/Webhooks/Handlers/KeyResult/KeyResultCreatedHandler.cs +++ b/ClickUp/Webhooks/Handlers/KeyResult/KeyResultCreatedHandler.cs @@ -7,7 +7,7 @@ public class KeyResultCreatedHandler : BaseWebhookHandler { protected override string EventType => "keyResultCreated"; - public KeyResultCreatedHandler([WebhookParameter] TeamRequest team) : base(team) + public KeyResultCreatedHandler([WebhookParameter] WebhookScopeRequest team) : base(team) { } } \ No newline at end of file diff --git a/ClickUp/Webhooks/Handlers/KeyResult/KeyResultDeletedHandler.cs b/ClickUp/Webhooks/Handlers/KeyResult/KeyResultDeletedHandler.cs index 4655aad..c569e2d 100644 --- a/ClickUp/Webhooks/Handlers/KeyResult/KeyResultDeletedHandler.cs +++ b/ClickUp/Webhooks/Handlers/KeyResult/KeyResultDeletedHandler.cs @@ -7,7 +7,7 @@ public class KeyResultDeletedHandler : BaseWebhookHandler { protected override string EventType => "keyResultDeleted"; - public KeyResultDeletedHandler([WebhookParameter] TeamRequest team) : base(team) + public KeyResultDeletedHandler([WebhookParameter] WebhookScopeRequest team) : base(team) { } } \ No newline at end of file diff --git a/ClickUp/Webhooks/Handlers/KeyResult/KeyResultUpdatedHandler.cs b/ClickUp/Webhooks/Handlers/KeyResult/KeyResultUpdatedHandler.cs index 918c0ab..69d1da1 100644 --- a/ClickUp/Webhooks/Handlers/KeyResult/KeyResultUpdatedHandler.cs +++ b/ClickUp/Webhooks/Handlers/KeyResult/KeyResultUpdatedHandler.cs @@ -7,7 +7,7 @@ public class KeyResultUpdatedHandler : BaseWebhookHandler { protected override string EventType => "keyResultUpdated"; - public KeyResultUpdatedHandler([WebhookParameter] TeamRequest team) : base(team) + public KeyResultUpdatedHandler([WebhookParameter] WebhookScopeRequest team) : base(team) { } } \ No newline at end of file diff --git a/ClickUp/Webhooks/Handlers/List/ListCreatedHandler.cs b/ClickUp/Webhooks/Handlers/List/ListCreatedHandler.cs index 09333d4..03468a3 100644 --- a/ClickUp/Webhooks/Handlers/List/ListCreatedHandler.cs +++ b/ClickUp/Webhooks/Handlers/List/ListCreatedHandler.cs @@ -7,7 +7,7 @@ public class ListCreatedHandler : BaseWebhookHandler { protected override string EventType => "listCreated"; - public ListCreatedHandler([WebhookParameter] TeamRequest team) : base(team) + public ListCreatedHandler([WebhookParameter] WebhookScopeRequest team) : base(team) { } } \ No newline at end of file diff --git a/ClickUp/Webhooks/Handlers/List/ListDeletedHandler.cs b/ClickUp/Webhooks/Handlers/List/ListDeletedHandler.cs index d54e0d4..5790478 100644 --- a/ClickUp/Webhooks/Handlers/List/ListDeletedHandler.cs +++ b/ClickUp/Webhooks/Handlers/List/ListDeletedHandler.cs @@ -7,7 +7,7 @@ public class ListDeletedHandler : BaseWebhookHandler { protected override string EventType => "listDeleted"; - public ListDeletedHandler([WebhookParameter] TeamRequest team) : base(team) + public ListDeletedHandler([WebhookParameter] WebhookScopeRequest team) : base(team) { } } \ No newline at end of file diff --git a/ClickUp/Webhooks/Handlers/List/ListUpdatedHandler.cs b/ClickUp/Webhooks/Handlers/List/ListUpdatedHandler.cs index e750824..158183a 100644 --- a/ClickUp/Webhooks/Handlers/List/ListUpdatedHandler.cs +++ b/ClickUp/Webhooks/Handlers/List/ListUpdatedHandler.cs @@ -7,7 +7,7 @@ public class ListUpdatedHandler : BaseWebhookHandler { protected override string EventType => "listUpdated"; - public ListUpdatedHandler([WebhookParameter] TeamRequest team) : base(team) + public ListUpdatedHandler([WebhookParameter] WebhookScopeRequest team) : base(team) { } } \ No newline at end of file diff --git a/ClickUp/Webhooks/Handlers/Space/SpaceCreatedHandler.cs b/ClickUp/Webhooks/Handlers/Space/SpaceCreatedHandler.cs index a2ddd35..1d5842e 100644 --- a/ClickUp/Webhooks/Handlers/Space/SpaceCreatedHandler.cs +++ b/ClickUp/Webhooks/Handlers/Space/SpaceCreatedHandler.cs @@ -7,7 +7,7 @@ public class SpaceCreatedHandler : BaseWebhookHandler { protected override string EventType => "spaceCreated"; - public SpaceCreatedHandler([WebhookParameter] TeamRequest team) : base(team) + public SpaceCreatedHandler([WebhookParameter] WebhookScopeRequest team) : base(team) { } } \ No newline at end of file diff --git a/ClickUp/Webhooks/Handlers/Space/SpaceDeletedHandler.cs b/ClickUp/Webhooks/Handlers/Space/SpaceDeletedHandler.cs index 295d2c6..d30ac20 100644 --- a/ClickUp/Webhooks/Handlers/Space/SpaceDeletedHandler.cs +++ b/ClickUp/Webhooks/Handlers/Space/SpaceDeletedHandler.cs @@ -7,7 +7,7 @@ public class SpaceDeletedHandler : BaseWebhookHandler { protected override string EventType => "spaceDeleted"; - public SpaceDeletedHandler([WebhookParameter] TeamRequest team) : base(team) + public SpaceDeletedHandler([WebhookParameter] WebhookScopeRequest team) : base(team) { } } \ No newline at end of file diff --git a/ClickUp/Webhooks/Handlers/Space/SpaceUpdatedHandler.cs b/ClickUp/Webhooks/Handlers/Space/SpaceUpdatedHandler.cs index b03810e..e1fd59b 100644 --- a/ClickUp/Webhooks/Handlers/Space/SpaceUpdatedHandler.cs +++ b/ClickUp/Webhooks/Handlers/Space/SpaceUpdatedHandler.cs @@ -7,7 +7,7 @@ public class SpaceUpdatedHandler : BaseWebhookHandler { protected override string EventType => "spaceUpdated"; - public SpaceUpdatedHandler([WebhookParameter] TeamRequest team) : base(team) + public SpaceUpdatedHandler([WebhookParameter] WebhookScopeRequest team) : base(team) { } } \ No newline at end of file diff --git a/ClickUp/Webhooks/Handlers/Tasks/DataHandlers/FolderWebhookDataHandler.cs b/ClickUp/Webhooks/Handlers/Tasks/DataHandlers/FolderWebhookDataHandler.cs new file mode 100644 index 0000000..ea548cc --- /dev/null +++ b/ClickUp/Webhooks/Handlers/Tasks/DataHandlers/FolderWebhookDataHandler.cs @@ -0,0 +1,15 @@ +using Apps.ClickUp.DataSourceHandlers.Folder; +using Blackbird.Applications.Sdk.Common.Invocation; +using Blackbird.Applications.Sdk.Common.Webhooks; + +namespace Apps.ClickUp.Webhooks.Handlers.Tasks.DataHandlers +{ + public class FolderWebhookDataHandler : FolderDataHandler + { + public FolderWebhookDataHandler(InvocationContext invocationContext, [WebhookParameter] WebhookScopeRequest request) : + base(invocationContext, request.SpaceId) + { + + } + } +} diff --git a/ClickUp/Webhooks/Handlers/Tasks/DataHandlers/ListWebhookDataHandler.cs b/ClickUp/Webhooks/Handlers/Tasks/DataHandlers/ListWebhookDataHandler.cs new file mode 100644 index 0000000..e6ec019 --- /dev/null +++ b/ClickUp/Webhooks/Handlers/Tasks/DataHandlers/ListWebhookDataHandler.cs @@ -0,0 +1,15 @@ +using Apps.ClickUp.DataSourceHandlers.List; +using Blackbird.Applications.Sdk.Common.Invocation; +using Blackbird.Applications.Sdk.Common.Webhooks; + +namespace Apps.ClickUp.Webhooks.Handlers.Tasks.DataHandlers +{ + internal class ListWebhookDataHandler : ListDataHandler + { + public ListWebhookDataHandler(InvocationContext invocationContext, [WebhookParameter] WebhookScopeRequest request) : + base(invocationContext, request.FolderId) + { + + } + } +} diff --git a/ClickUp/Webhooks/Handlers/Tasks/DataHandlers/SpaceWebhookDataHandler.cs b/ClickUp/Webhooks/Handlers/Tasks/DataHandlers/SpaceWebhookDataHandler.cs new file mode 100644 index 0000000..8729826 --- /dev/null +++ b/ClickUp/Webhooks/Handlers/Tasks/DataHandlers/SpaceWebhookDataHandler.cs @@ -0,0 +1,15 @@ +using Apps.ClickUp.DataSourceHandlers.Space; +using Blackbird.Applications.Sdk.Common.Invocation; +using Blackbird.Applications.Sdk.Common.Webhooks; + +namespace Apps.ClickUp.Webhooks.Handlers.Tasks.DataHandlers +{ + public class SpaceWebhookDataHandler : SpaceDataHandler + { + public SpaceWebhookDataHandler(InvocationContext invocationContext, [WebhookParameter] WebhookScopeRequest request) : + base(invocationContext, request.TeamId) + { + + } + } +} diff --git a/ClickUp/Webhooks/Handlers/Tasks/DataHandlers/TaskWebhookDataHandler.cs b/ClickUp/Webhooks/Handlers/Tasks/DataHandlers/TaskWebhookDataHandler.cs new file mode 100644 index 0000000..69ff303 --- /dev/null +++ b/ClickUp/Webhooks/Handlers/Tasks/DataHandlers/TaskWebhookDataHandler.cs @@ -0,0 +1,16 @@ +using Apps.ClickUp.DataSourceHandlers.Task; +using Apps.ClickUp.Models.Request.Task; +using Blackbird.Applications.Sdk.Common; +using Blackbird.Applications.Sdk.Common.Invocation; + +namespace Apps.ClickUp.Webhooks.Handlers.Tasks.DataHandlers +{ + public class TaskWebhookDataHandler : TaskDataHandler + { + public TaskWebhookDataHandler(InvocationContext invocationContext, [ActionParameter] TaskRequest request) : + base(invocationContext, request.ListId) + { + + } + } +} diff --git a/ClickUp/Webhooks/Handlers/Tasks/TaskAssigneeUpdatedHandler.cs b/ClickUp/Webhooks/Handlers/Tasks/TaskAssigneeUpdatedHandler.cs index a01b8a4..f620352 100644 --- a/ClickUp/Webhooks/Handlers/Tasks/TaskAssigneeUpdatedHandler.cs +++ b/ClickUp/Webhooks/Handlers/Tasks/TaskAssigneeUpdatedHandler.cs @@ -7,7 +7,7 @@ public class TaskAssigneeUpdatedHandler : BaseWebhookHandler { protected override string EventType => "taskAssigneeUpdated"; - public TaskAssigneeUpdatedHandler([WebhookParameter] TeamRequest team) : base(team) + public TaskAssigneeUpdatedHandler([WebhookParameter] WebhookScopeRequest team) : base(team) { } } \ No newline at end of file diff --git a/ClickUp/Webhooks/Handlers/Tasks/TaskCommentPostedHandler.cs b/ClickUp/Webhooks/Handlers/Tasks/TaskCommentPostedHandler.cs index c4a3a65..8fbb4a1 100644 --- a/ClickUp/Webhooks/Handlers/Tasks/TaskCommentPostedHandler.cs +++ b/ClickUp/Webhooks/Handlers/Tasks/TaskCommentPostedHandler.cs @@ -7,7 +7,7 @@ public class TaskCommentPostedHandler : BaseWebhookHandler { protected override string EventType => "taskCommentPosted"; - public TaskCommentPostedHandler([WebhookParameter] TeamRequest team) : base(team) + public TaskCommentPostedHandler([WebhookParameter] WebhookScopeRequest team) : base(team) { } } \ No newline at end of file diff --git a/ClickUp/Webhooks/Handlers/Tasks/TaskCommentUpdatedHandler.cs b/ClickUp/Webhooks/Handlers/Tasks/TaskCommentUpdatedHandler.cs index 2b8f99c..3074c00 100644 --- a/ClickUp/Webhooks/Handlers/Tasks/TaskCommentUpdatedHandler.cs +++ b/ClickUp/Webhooks/Handlers/Tasks/TaskCommentUpdatedHandler.cs @@ -7,7 +7,7 @@ public class TaskCommentUpdatedHandler : BaseWebhookHandler { protected override string EventType => "taskCommentUpdated"; - public TaskCommentUpdatedHandler([WebhookParameter] TeamRequest team) : base(team) + public TaskCommentUpdatedHandler([WebhookParameter] WebhookScopeRequest team) : base(team) { } } \ No newline at end of file diff --git a/ClickUp/Webhooks/Handlers/Tasks/TaskCreatedHandler.cs b/ClickUp/Webhooks/Handlers/Tasks/TaskCreatedHandler.cs index 3ffb40c..273749f 100644 --- a/ClickUp/Webhooks/Handlers/Tasks/TaskCreatedHandler.cs +++ b/ClickUp/Webhooks/Handlers/Tasks/TaskCreatedHandler.cs @@ -7,7 +7,7 @@ public class TaskCreatedHandler : BaseWebhookHandler { protected override string EventType => "taskCreated"; - public TaskCreatedHandler([WebhookParameter] TeamRequest team) : base(team) + public TaskCreatedHandler([WebhookParameter] WebhookScopeRequest team) : base(team) { } } \ No newline at end of file diff --git a/ClickUp/Webhooks/Handlers/Tasks/TaskDeletedHandler.cs b/ClickUp/Webhooks/Handlers/Tasks/TaskDeletedHandler.cs index 9bfa553..501965b 100644 --- a/ClickUp/Webhooks/Handlers/Tasks/TaskDeletedHandler.cs +++ b/ClickUp/Webhooks/Handlers/Tasks/TaskDeletedHandler.cs @@ -7,7 +7,7 @@ public class TaskDeletedHandler : BaseWebhookHandler { protected override string EventType => "taskDeleted"; - public TaskDeletedHandler([WebhookParameter] TeamRequest team) : base(team) + public TaskDeletedHandler([WebhookParameter] WebhookScopeRequest team) : base(team) { } } \ No newline at end of file diff --git a/ClickUp/Webhooks/Handlers/Tasks/TaskDueDateUpdatedHandler.cs b/ClickUp/Webhooks/Handlers/Tasks/TaskDueDateUpdatedHandler.cs index 6802ef5..9cd912e 100644 --- a/ClickUp/Webhooks/Handlers/Tasks/TaskDueDateUpdatedHandler.cs +++ b/ClickUp/Webhooks/Handlers/Tasks/TaskDueDateUpdatedHandler.cs @@ -7,7 +7,7 @@ public class TaskDueDateUpdatedHandler : BaseWebhookHandler { protected override string EventType => "taskDueDateUpdated"; - public TaskDueDateUpdatedHandler([WebhookParameter] TeamRequest team) : base(team) + public TaskDueDateUpdatedHandler([WebhookParameter] WebhookScopeRequest team) : base(team) { } } \ No newline at end of file diff --git a/ClickUp/Webhooks/Handlers/Tasks/TaskMovedHandler.cs b/ClickUp/Webhooks/Handlers/Tasks/TaskMovedHandler.cs index aa74bb3..804d9d1 100644 --- a/ClickUp/Webhooks/Handlers/Tasks/TaskMovedHandler.cs +++ b/ClickUp/Webhooks/Handlers/Tasks/TaskMovedHandler.cs @@ -7,7 +7,7 @@ public class TaskMovedHandler : BaseWebhookHandler { protected override string EventType => "taskMoved"; - public TaskMovedHandler([WebhookParameter] TeamRequest team) : base(team) + public TaskMovedHandler([WebhookParameter] WebhookScopeRequest team) : base(team) { } } \ No newline at end of file diff --git a/ClickUp/Webhooks/Handlers/Tasks/TaskPriorityUpdatedHandler.cs b/ClickUp/Webhooks/Handlers/Tasks/TaskPriorityUpdatedHandler.cs index 1901b19..6f26b73 100644 --- a/ClickUp/Webhooks/Handlers/Tasks/TaskPriorityUpdatedHandler.cs +++ b/ClickUp/Webhooks/Handlers/Tasks/TaskPriorityUpdatedHandler.cs @@ -7,7 +7,7 @@ public class TaskPriorityUpdatedHandler : BaseWebhookHandler { protected override string EventType => "taskPriorityUpdated"; - public TaskPriorityUpdatedHandler([WebhookParameter] TeamRequest team) : base(team) + public TaskPriorityUpdatedHandler([WebhookParameter] WebhookScopeRequest team) : base(team) { } } \ No newline at end of file diff --git a/ClickUp/Webhooks/Handlers/Tasks/TaskStatusUpdatedHandler.cs b/ClickUp/Webhooks/Handlers/Tasks/TaskStatusUpdatedHandler.cs index 52ec5ee..d7c362f 100644 --- a/ClickUp/Webhooks/Handlers/Tasks/TaskStatusUpdatedHandler.cs +++ b/ClickUp/Webhooks/Handlers/Tasks/TaskStatusUpdatedHandler.cs @@ -7,7 +7,7 @@ public class TaskStatusUpdatedHandler : BaseWebhookHandler { protected override string EventType => "taskStatusUpdated"; - public TaskStatusUpdatedHandler([WebhookParameter] TeamRequest team) : base(team) + public TaskStatusUpdatedHandler([WebhookParameter] WebhookScopeRequest team) : base(team) { } } \ No newline at end of file diff --git a/ClickUp/Webhooks/Handlers/Tasks/TaskTagUpdatedHandler.cs b/ClickUp/Webhooks/Handlers/Tasks/TaskTagUpdatedHandler.cs index f2537ee..58c1f47 100644 --- a/ClickUp/Webhooks/Handlers/Tasks/TaskTagUpdatedHandler.cs +++ b/ClickUp/Webhooks/Handlers/Tasks/TaskTagUpdatedHandler.cs @@ -7,7 +7,7 @@ public class TaskTagUpdatedHandler : BaseWebhookHandler { protected override string EventType => "taskTagUpdated"; - public TaskTagUpdatedHandler([WebhookParameter] TeamRequest team) : base(team) + public TaskTagUpdatedHandler([WebhookParameter] WebhookScopeRequest team) : base(team) { } } \ No newline at end of file diff --git a/ClickUp/Webhooks/Handlers/Tasks/TaskTimeEstimateUpdatedHandler.cs b/ClickUp/Webhooks/Handlers/Tasks/TaskTimeEstimateUpdatedHandler.cs index f097cb3..186aa3a 100644 --- a/ClickUp/Webhooks/Handlers/Tasks/TaskTimeEstimateUpdatedHandler.cs +++ b/ClickUp/Webhooks/Handlers/Tasks/TaskTimeEstimateUpdatedHandler.cs @@ -7,7 +7,7 @@ public class TaskTimeEstimateUpdatedHandler : BaseWebhookHandler { protected override string EventType => "taskTimeEstimateUpdated"; - public TaskTimeEstimateUpdatedHandler([WebhookParameter] TeamRequest team) : base(team) + public TaskTimeEstimateUpdatedHandler([WebhookParameter] WebhookScopeRequest team) : base(team) { } } \ No newline at end of file diff --git a/ClickUp/Webhooks/Handlers/Tasks/TaskTimeTrackedUpdatedHandler.cs b/ClickUp/Webhooks/Handlers/Tasks/TaskTimeTrackedUpdatedHandler.cs index 2ab5b69..a1818a0 100644 --- a/ClickUp/Webhooks/Handlers/Tasks/TaskTimeTrackedUpdatedHandler.cs +++ b/ClickUp/Webhooks/Handlers/Tasks/TaskTimeTrackedUpdatedHandler.cs @@ -7,7 +7,7 @@ public class TaskTimeTrackedUpdatedHandler : BaseWebhookHandler { protected override string EventType => "taskTimeTrackedUpdated"; - public TaskTimeTrackedUpdatedHandler([WebhookParameter] TeamRequest team) : base(team) + public TaskTimeTrackedUpdatedHandler([WebhookParameter] WebhookScopeRequest team) : base(team) { } } \ No newline at end of file diff --git a/ClickUp/Webhooks/Handlers/Tasks/TaskUpdatedHandler.cs b/ClickUp/Webhooks/Handlers/Tasks/TaskUpdatedHandler.cs index a2ba4b3..3261f64 100644 --- a/ClickUp/Webhooks/Handlers/Tasks/TaskUpdatedHandler.cs +++ b/ClickUp/Webhooks/Handlers/Tasks/TaskUpdatedHandler.cs @@ -7,7 +7,7 @@ public class TaskUpdatedHandler : BaseWebhookHandler { protected override string EventType => "taskUpdated"; - public TaskUpdatedHandler([WebhookParameter] TeamRequest team) : base(team) + public TaskUpdatedHandler([WebhookParameter] WebhookScopeRequest team) : base(team) { } } \ No newline at end of file diff --git a/ClickUp/Webhooks/Handlers/WebhookScopeRequest.cs b/ClickUp/Webhooks/Handlers/WebhookScopeRequest.cs new file mode 100644 index 0000000..f2d058e --- /dev/null +++ b/ClickUp/Webhooks/Handlers/WebhookScopeRequest.cs @@ -0,0 +1,30 @@ +using Apps.ClickUp.DataSourceHandlers; +using Apps.ClickUp.Webhooks.Handlers.Tasks.DataHandlers; +using Blackbird.Applications.Sdk.Common; +using Blackbird.Applications.Sdk.Common.Dynamic; + +namespace Apps.ClickUp.Webhooks.Handlers +{ + public class WebhookScopeRequest + { + [Display("Team")] + [DataSource(typeof(TeamDataHandler))] + public string TeamId { get; set; } + + [Display("Space ID")] + [DataSource(typeof(SpaceWebhookDataHandler))] + public string? SpaceId { get; set; } + + [Display("Folder ID")] + [DataSource(typeof(FolderWebhookDataHandler))] + public string? FolderId { get; set; } + + [Display("List ID")] + [DataSource(typeof(ListWebhookDataHandler))] + public string? ListId { get; set; } + + [Display("Task ID")] + [DataSource(typeof(TaskWebhookDataHandler))] + public string? TaskId { get; set; } + } +} diff --git a/ClickUp/Webhooks/Models/Request/AddWebhookRequest.cs b/ClickUp/Webhooks/Models/Request/AddWebhookRequest.cs index 669f786..36fc583 100644 --- a/ClickUp/Webhooks/Models/Request/AddWebhookRequest.cs +++ b/ClickUp/Webhooks/Models/Request/AddWebhookRequest.cs @@ -1,7 +1,24 @@ -namespace Apps.ClickUp.Webhooks.Models.Request; +using Newtonsoft.Json; + +namespace Apps.ClickUp.Webhooks.Models.Request; public class AddWebhookRequest { - public string Endpoint { get; set; } - public List Events { get; set; } + [JsonProperty("endpoint")] + public string Endpoint { get; set; } = default!; + + [JsonProperty("events")] + public List Events { get; set; } = new(); + + [JsonProperty("space_id")] + public long? SpaceId { get; set; } + + [JsonProperty("folder_id")] + public long? FolderId { get; set; } + + [JsonProperty("list_id")] + public long? ListId { get; set; } + + [JsonProperty("task_id")] + public string? TaskId { get; set; } } \ No newline at end of file diff --git a/Tests.ClickUp/TestFiles/Input/test.txt b/Tests.ClickUp/TestFiles/Input/test.txt deleted file mode 100644 index 6769dd6..0000000 --- a/Tests.ClickUp/TestFiles/Input/test.txt +++ /dev/null @@ -1 +0,0 @@ -Hello world! \ No newline at end of file diff --git a/Tests.ClickUp/Tests.ClickUp.csproj b/Tests.ClickUp/Tests.ClickUp.csproj index 5243457..f8e6763 100644 --- a/Tests.ClickUp/Tests.ClickUp.csproj +++ b/Tests.ClickUp/Tests.ClickUp.csproj @@ -31,6 +31,7 @@ + From 15cb7485cfc61c7c624023e84bf397ee41197eb4 Mon Sep 17 00:00:00 2001 From: Artem Riabushenko Date: Thu, 29 Jan 2026 14:26:58 +0200 Subject: [PATCH 3/4] Fixes to data tag data handlers --- .../Handlers/Tasks/DataHandlers/FolderWebhookDataHandler.cs | 2 +- .../Handlers/Tasks/DataHandlers/ListWebhookDataHandler.cs | 2 +- .../Handlers/Tasks/DataHandlers/SpaceWebhookDataHandler.cs | 2 +- .../Handlers/Tasks/DataHandlers/TaskWebhookDataHandler.cs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ClickUp/Webhooks/Handlers/Tasks/DataHandlers/FolderWebhookDataHandler.cs b/ClickUp/Webhooks/Handlers/Tasks/DataHandlers/FolderWebhookDataHandler.cs index ea548cc..c2abd79 100644 --- a/ClickUp/Webhooks/Handlers/Tasks/DataHandlers/FolderWebhookDataHandler.cs +++ b/ClickUp/Webhooks/Handlers/Tasks/DataHandlers/FolderWebhookDataHandler.cs @@ -6,7 +6,7 @@ namespace Apps.ClickUp.Webhooks.Handlers.Tasks.DataHandlers { public class FolderWebhookDataHandler : FolderDataHandler { - public FolderWebhookDataHandler(InvocationContext invocationContext, [WebhookParameter] WebhookScopeRequest request) : + public FolderWebhookDataHandler(InvocationContext invocationContext, WebhookScopeRequest request) : base(invocationContext, request.SpaceId) { diff --git a/ClickUp/Webhooks/Handlers/Tasks/DataHandlers/ListWebhookDataHandler.cs b/ClickUp/Webhooks/Handlers/Tasks/DataHandlers/ListWebhookDataHandler.cs index e6ec019..13a7e60 100644 --- a/ClickUp/Webhooks/Handlers/Tasks/DataHandlers/ListWebhookDataHandler.cs +++ b/ClickUp/Webhooks/Handlers/Tasks/DataHandlers/ListWebhookDataHandler.cs @@ -6,7 +6,7 @@ namespace Apps.ClickUp.Webhooks.Handlers.Tasks.DataHandlers { internal class ListWebhookDataHandler : ListDataHandler { - public ListWebhookDataHandler(InvocationContext invocationContext, [WebhookParameter] WebhookScopeRequest request) : + public ListWebhookDataHandler(InvocationContext invocationContext,WebhookScopeRequest request) : base(invocationContext, request.FolderId) { diff --git a/ClickUp/Webhooks/Handlers/Tasks/DataHandlers/SpaceWebhookDataHandler.cs b/ClickUp/Webhooks/Handlers/Tasks/DataHandlers/SpaceWebhookDataHandler.cs index 8729826..a245c22 100644 --- a/ClickUp/Webhooks/Handlers/Tasks/DataHandlers/SpaceWebhookDataHandler.cs +++ b/ClickUp/Webhooks/Handlers/Tasks/DataHandlers/SpaceWebhookDataHandler.cs @@ -6,7 +6,7 @@ namespace Apps.ClickUp.Webhooks.Handlers.Tasks.DataHandlers { public class SpaceWebhookDataHandler : SpaceDataHandler { - public SpaceWebhookDataHandler(InvocationContext invocationContext, [WebhookParameter] WebhookScopeRequest request) : + public SpaceWebhookDataHandler(InvocationContext invocationContext, WebhookScopeRequest request) : base(invocationContext, request.TeamId) { diff --git a/ClickUp/Webhooks/Handlers/Tasks/DataHandlers/TaskWebhookDataHandler.cs b/ClickUp/Webhooks/Handlers/Tasks/DataHandlers/TaskWebhookDataHandler.cs index 69ff303..aaf84e1 100644 --- a/ClickUp/Webhooks/Handlers/Tasks/DataHandlers/TaskWebhookDataHandler.cs +++ b/ClickUp/Webhooks/Handlers/Tasks/DataHandlers/TaskWebhookDataHandler.cs @@ -7,7 +7,7 @@ namespace Apps.ClickUp.Webhooks.Handlers.Tasks.DataHandlers { public class TaskWebhookDataHandler : TaskDataHandler { - public TaskWebhookDataHandler(InvocationContext invocationContext, [ActionParameter] TaskRequest request) : + public TaskWebhookDataHandler(InvocationContext invocationContext, WebhookScopeRequest request) : base(invocationContext, request.ListId) { From b4a13e7acc268cc9324191b14f782914c9b20e44 Mon Sep 17 00:00:00 2001 From: Artem Riabushenko Date: Thu, 29 Jan 2026 14:32:20 +0200 Subject: [PATCH 4/4] Fixes to data tag data handlers --- .../Handlers/Tasks/DataHandlers/FolderWebhookDataHandler.cs | 3 ++- .../Handlers/Tasks/DataHandlers/ListWebhookDataHandler.cs | 3 ++- .../Handlers/Tasks/DataHandlers/SpaceWebhookDataHandler.cs | 3 ++- .../Handlers/Tasks/DataHandlers/TaskWebhookDataHandler.cs | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ClickUp/Webhooks/Handlers/Tasks/DataHandlers/FolderWebhookDataHandler.cs b/ClickUp/Webhooks/Handlers/Tasks/DataHandlers/FolderWebhookDataHandler.cs index c2abd79..4474e09 100644 --- a/ClickUp/Webhooks/Handlers/Tasks/DataHandlers/FolderWebhookDataHandler.cs +++ b/ClickUp/Webhooks/Handlers/Tasks/DataHandlers/FolderWebhookDataHandler.cs @@ -1,4 +1,5 @@ using Apps.ClickUp.DataSourceHandlers.Folder; +using Blackbird.Applications.Sdk.Common; using Blackbird.Applications.Sdk.Common.Invocation; using Blackbird.Applications.Sdk.Common.Webhooks; @@ -6,7 +7,7 @@ namespace Apps.ClickUp.Webhooks.Handlers.Tasks.DataHandlers { public class FolderWebhookDataHandler : FolderDataHandler { - public FolderWebhookDataHandler(InvocationContext invocationContext, WebhookScopeRequest request) : + public FolderWebhookDataHandler(InvocationContext invocationContext, [ActionParameter] WebhookScopeRequest request) : base(invocationContext, request.SpaceId) { diff --git a/ClickUp/Webhooks/Handlers/Tasks/DataHandlers/ListWebhookDataHandler.cs b/ClickUp/Webhooks/Handlers/Tasks/DataHandlers/ListWebhookDataHandler.cs index 13a7e60..25b005e 100644 --- a/ClickUp/Webhooks/Handlers/Tasks/DataHandlers/ListWebhookDataHandler.cs +++ b/ClickUp/Webhooks/Handlers/Tasks/DataHandlers/ListWebhookDataHandler.cs @@ -1,4 +1,5 @@ using Apps.ClickUp.DataSourceHandlers.List; +using Blackbird.Applications.Sdk.Common; using Blackbird.Applications.Sdk.Common.Invocation; using Blackbird.Applications.Sdk.Common.Webhooks; @@ -6,7 +7,7 @@ namespace Apps.ClickUp.Webhooks.Handlers.Tasks.DataHandlers { internal class ListWebhookDataHandler : ListDataHandler { - public ListWebhookDataHandler(InvocationContext invocationContext,WebhookScopeRequest request) : + public ListWebhookDataHandler(InvocationContext invocationContext, [ActionParameter] WebhookScopeRequest request) : base(invocationContext, request.FolderId) { diff --git a/ClickUp/Webhooks/Handlers/Tasks/DataHandlers/SpaceWebhookDataHandler.cs b/ClickUp/Webhooks/Handlers/Tasks/DataHandlers/SpaceWebhookDataHandler.cs index a245c22..bc7485e 100644 --- a/ClickUp/Webhooks/Handlers/Tasks/DataHandlers/SpaceWebhookDataHandler.cs +++ b/ClickUp/Webhooks/Handlers/Tasks/DataHandlers/SpaceWebhookDataHandler.cs @@ -1,4 +1,5 @@ using Apps.ClickUp.DataSourceHandlers.Space; +using Blackbird.Applications.Sdk.Common; using Blackbird.Applications.Sdk.Common.Invocation; using Blackbird.Applications.Sdk.Common.Webhooks; @@ -6,7 +7,7 @@ namespace Apps.ClickUp.Webhooks.Handlers.Tasks.DataHandlers { public class SpaceWebhookDataHandler : SpaceDataHandler { - public SpaceWebhookDataHandler(InvocationContext invocationContext, WebhookScopeRequest request) : + public SpaceWebhookDataHandler(InvocationContext invocationContext, [ActionParameter] WebhookScopeRequest request) : base(invocationContext, request.TeamId) { diff --git a/ClickUp/Webhooks/Handlers/Tasks/DataHandlers/TaskWebhookDataHandler.cs b/ClickUp/Webhooks/Handlers/Tasks/DataHandlers/TaskWebhookDataHandler.cs index aaf84e1..cfe7bdc 100644 --- a/ClickUp/Webhooks/Handlers/Tasks/DataHandlers/TaskWebhookDataHandler.cs +++ b/ClickUp/Webhooks/Handlers/Tasks/DataHandlers/TaskWebhookDataHandler.cs @@ -7,7 +7,7 @@ namespace Apps.ClickUp.Webhooks.Handlers.Tasks.DataHandlers { public class TaskWebhookDataHandler : TaskDataHandler { - public TaskWebhookDataHandler(InvocationContext invocationContext, WebhookScopeRequest request) : + public TaskWebhookDataHandler(InvocationContext invocationContext, [ActionParameter] WebhookScopeRequest request) : base(invocationContext, request.ListId) {