From 30ed3b450976b7b381023e962e46042079527a9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Bia=C5=82ecki?= Date: Fri, 14 Jul 2023 23:06:06 +0200 Subject: [PATCH] Small rename --- .../ProjectFolders/CleanUpProjectTests.cs | 6 +-- .../ProjectFolders/FindProjectByIdTests.cs | 6 +-- .../ProjectFolders/RemoveProjectTests.cs | 6 +-- .../ProjectFolders/UpdateProjectTests.cs | 6 ++- .../ProjectFolders/ProjectFoldersClient.cs | 38 ++++++++++--------- 5 files changed, 33 insertions(+), 29 deletions(-) diff --git a/Egnyte.Api.Tests/ProjectFolders/CleanUpProjectTests.cs b/Egnyte.Api.Tests/ProjectFolders/CleanUpProjectTests.cs index 6f1663f..6a8a552 100644 --- a/Egnyte.Api.Tests/ProjectFolders/CleanUpProjectTests.cs +++ b/Egnyte.Api.Tests/ProjectFolders/CleanUpProjectTests.cs @@ -25,7 +25,7 @@ public async Task CleanUpProject_ReturnsSuccess() }); var egnyteClient = new EgnyteClient("token", "acme", httpClient); - var cleanupProjectResponse = await egnyteClient.ProjectFolders.CleanUpProject(projectId: "ABC123", true); + var cleanupProjectResponse = await egnyteClient.ProjectFolders.CleanUpProject(id: "ABC123", true); var requestMessage = httpHandlerMock.GetHttpRequestMessage(); Assert.AreEqual( @@ -42,9 +42,9 @@ public async Task CleanUpProject_WhenProjectIdIsEmpty_ThrowsArgumentNullExceptio var egnyteClient = new EgnyteClient("token", "acme", httpClient); var exception = await AssertExtensions.ThrowsAsync( - () => egnyteClient.ProjectFolders.CleanUpProject(projectId: string.Empty, true)); + () => egnyteClient.ProjectFolders.CleanUpProject(id: string.Empty, true)); - Assert.IsTrue(exception.Message.Contains("projectId")); + Assert.IsTrue(exception.Message.Contains("id")); Assert.IsNull(exception.InnerException); } } diff --git a/Egnyte.Api.Tests/ProjectFolders/FindProjectByIdTests.cs b/Egnyte.Api.Tests/ProjectFolders/FindProjectByIdTests.cs index d66e688..8e2edf4 100644 --- a/Egnyte.Api.Tests/ProjectFolders/FindProjectByIdTests.cs +++ b/Egnyte.Api.Tests/ProjectFolders/FindProjectByIdTests.cs @@ -1,9 +1,7 @@ using NUnit.Framework; using System; -using System.Collections.Generic; using System.Net.Http; using System.Net; -using System.Text; using System.Threading.Tasks; namespace Egnyte.Api.Tests.ProjectFolders @@ -87,9 +85,9 @@ public async Task FindProjectById_WhenProjectIdIsEmpty_ThrowsArgumentNullExcepti var egnyteClient = new EgnyteClient("token", "acme", httpClient); var exception = await AssertExtensions.ThrowsAsync( - () => egnyteClient.ProjectFolders.FindProjectById(projectId: string.Empty)); + () => egnyteClient.ProjectFolders.FindProjectById(id: string.Empty)); - Assert.IsTrue(exception.Message.Contains("projectId")); + Assert.IsTrue(exception.Message.Contains("id")); Assert.IsNull(exception.InnerException); } } diff --git a/Egnyte.Api.Tests/ProjectFolders/RemoveProjectTests.cs b/Egnyte.Api.Tests/ProjectFolders/RemoveProjectTests.cs index 6a88717..0fcf6b7 100644 --- a/Egnyte.Api.Tests/ProjectFolders/RemoveProjectTests.cs +++ b/Egnyte.Api.Tests/ProjectFolders/RemoveProjectTests.cs @@ -25,7 +25,7 @@ public async Task RemoveProject_ReturnsSuccess() }); var egnyteClient = new EgnyteClient("token", "acme", httpClient); - var removeProjectResponse = await egnyteClient.ProjectFolders.RemoveProject(projectId: "ABC-123"); + var removeProjectResponse = await egnyteClient.ProjectFolders.RemoveProject(id: "ABC-123"); var requestMessage = httpHandlerMock.GetHttpRequestMessage(); Assert.AreEqual( @@ -42,9 +42,9 @@ public async Task RemoveProject_WhenProjectIdIsEmpty_ThrowsArgumentNullException var egnyteClient = new EgnyteClient("token", "acme", httpClient); var exception = await AssertExtensions.ThrowsAsync( - () => egnyteClient.ProjectFolders.RemoveProject(projectId: string.Empty)); + () => egnyteClient.ProjectFolders.RemoveProject(id: string.Empty)); - Assert.IsTrue(exception.Message.Contains("projectId")); + Assert.IsTrue(exception.Message.Contains("id")); Assert.IsNull(exception.InnerException); } } diff --git a/Egnyte.Api.Tests/ProjectFolders/UpdateProjectTests.cs b/Egnyte.Api.Tests/ProjectFolders/UpdateProjectTests.cs index 10f1329..5548392 100644 --- a/Egnyte.Api.Tests/ProjectFolders/UpdateProjectTests.cs +++ b/Egnyte.Api.Tests/ProjectFolders/UpdateProjectTests.cs @@ -27,6 +27,7 @@ public async Task UpdateProject_ReturnsSuccess() var egnyteClient = new EgnyteClient("token", "acme", httpClient); var updateProjectResponse = await egnyteClient.ProjectFolders.UpdateProject( name: "Acme Widgets HQ", + id: "P123", status: "pending", projectId: "ABC123", customerName: "Acme Widgets", @@ -43,7 +44,7 @@ public async Task UpdateProject_ReturnsSuccess() var requestMessage = httpHandlerMock.GetHttpRequestMessage(); Assert.AreEqual( - "https://acme.egnyte.com/pubapi/v2/project-folders/ABC123", + "https://acme.egnyte.com/pubapi/v2/project-folders/P123", requestMessage.RequestUri.ToString()); Assert.AreEqual(HttpMethod.Patch, requestMessage.Method); Assert.IsTrue(updateProjectResponse); @@ -58,6 +59,7 @@ public async Task UpdateProject_WhenNameIsEmpty_ThrowsArgumentNullException() var exception = await AssertExtensions.ThrowsAsync( () => egnyteClient.ProjectFolders.UpdateProject( name: string.Empty, + id: "P123", status: "pending", projectId: "ABC123")); @@ -74,6 +76,7 @@ public async Task UpdateProject_WhenStatusIsEmpty_ThrowsArgumentNullException() var exception = await AssertExtensions.ThrowsAsync( () => egnyteClient.ProjectFolders.UpdateProject( name: "Acme Widgets HQ", + id: "P123", status: string.Empty, projectId: "ABC123")); @@ -90,6 +93,7 @@ public async Task UpdateProject_WhenProjectIdIsEmpty_ThrowsArgumentNullException var exception = await AssertExtensions.ThrowsAsync( () => egnyteClient.ProjectFolders.UpdateProject( name: "Acme Widgets HQ", + id: "P123", status: "pending", projectId: string.Empty)); diff --git a/Egnyte.Api/ProjectFolders/ProjectFoldersClient.cs b/Egnyte.Api/ProjectFolders/ProjectFoldersClient.cs index 53a9384..095680d 100644 --- a/Egnyte.Api/ProjectFolders/ProjectFoldersClient.cs +++ b/Egnyte.Api/ProjectFolders/ProjectFoldersClient.cs @@ -94,17 +94,17 @@ public async Task MarkFolderAsProject( /// /// Retrieve a project based on its Id /// - /// Project Id + /// Project Id /// Project details /// - public async Task FindProjectById(string projectId) + public async Task FindProjectById(string id) { - if (string.IsNullOrWhiteSpace(projectId)) + if (string.IsNullOrWhiteSpace(id)) { - throw new ArgumentNullException(nameof(projectId)); + throw new ArgumentNullException(nameof(id)); } - var uriBuilder = BuildUri(ProjectFoldersMethodV2 + "/" + projectId); + var uriBuilder = BuildUri(ProjectFoldersMethodV2 + "/" + id); var httpRequest = new HttpRequestMessage(HttpMethod.Get, uriBuilder.Uri); var serviceHandler = new ServiceHandler(httpClient); @@ -227,17 +227,17 @@ public async Task CreateProjectFromTemplate( /// /// Remove a project /// - /// Project Id + /// Project Id /// True if succeeded, False otherwise /// - public async Task RemoveProject(string projectId) + public async Task RemoveProject(string id) { - if (string.IsNullOrWhiteSpace(projectId)) + if (string.IsNullOrWhiteSpace(id)) { - throw new ArgumentNullException(nameof(projectId)); + throw new ArgumentNullException(nameof(id)); } - var uriBuilder = BuildUri(ProjectFoldersMethodV2 + "/" + projectId); + var uriBuilder = BuildUri(ProjectFoldersMethodV2 + "/" + id); var httpRequest = new HttpRequestMessage(HttpMethod.Delete, uriBuilder.Uri); var serviceHandler = new ServiceHandler(httpClient); @@ -248,8 +248,9 @@ public async Task RemoveProject(string projectId) /// /// Update existing project /// + /// Id of the project /// The name of the project - /// ID of the project + /// id /// Status of the project. Possible values: pending, in-progress, or on-hold /// Optional. Folder description /// Optional. The customer associated with the project @@ -260,6 +261,7 @@ public async Task RemoveProject(string projectId) /// public async Task UpdateProject( string name, + string id, string projectId, string status, string description = null, @@ -283,7 +285,7 @@ public async Task UpdateProject( throw new ArgumentNullException(nameof(status)); } - var uriBuilder = BuildUri(ProjectFoldersMethodV2 + "/" + projectId); + var uriBuilder = BuildUri(ProjectFoldersMethodV2 + "/" + id); var httpRequest = new HttpRequestMessage(new HttpMethod("PATCH"), uriBuilder.Uri) { Content = new StringContent( @@ -312,24 +314,24 @@ public async Task UpdateProject( /// /// Clean up a project /// - /// Project Id + /// Project Id /// If set to true, all existing active links in the project will be deleted /// List of User Ids to be deleted /// List of User Ids to be disabled /// True if succeeded /// public async Task CleanUpProject( - string projectId, + string id, bool deleteLinks, List usersToDelete = null, List usersToDisable = null) { - if (string.IsNullOrWhiteSpace(projectId)) + if (string.IsNullOrWhiteSpace(id)) { - throw new ArgumentNullException(nameof(projectId)); + throw new ArgumentNullException(nameof(id)); } - var uriBuilder = BuildUri(ProjectFoldersMethod + "/" + projectId + "/cleanup"); + var uriBuilder = BuildUri(ProjectFoldersMethod + "/" + id + "/cleanup"); var httpRequest = new HttpRequestMessage(HttpMethod.Post, uriBuilder.Uri) { Content = new StringContent( @@ -384,7 +386,7 @@ private string MapCreateProjectRequest( } if (!string.IsNullOrWhiteSpace(projectId)) { - builder.Append("\"projectId\" : \"" + projectId + "\","); + builder.Append("\"id\" : \"" + projectId + "\","); } if (!string.IsNullOrWhiteSpace(customerName)) {