Skip to content

Commit

Permalink
Small rename
Browse files Browse the repository at this point in the history
  • Loading branch information
Michał Białecki committed Jul 14, 2023
1 parent 3d3178b commit 30ed3b4
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 29 deletions.
6 changes: 3 additions & 3 deletions Egnyte.Api.Tests/ProjectFolders/CleanUpProjectTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -42,9 +42,9 @@ public async Task CleanUpProject_WhenProjectIdIsEmpty_ThrowsArgumentNullExceptio
var egnyteClient = new EgnyteClient("token", "acme", httpClient);

var exception = await AssertExtensions.ThrowsAsync<ArgumentNullException>(
() => 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);
}
}
Expand Down
6 changes: 2 additions & 4 deletions Egnyte.Api.Tests/ProjectFolders/FindProjectByIdTests.cs
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -87,9 +85,9 @@ public async Task FindProjectById_WhenProjectIdIsEmpty_ThrowsArgumentNullExcepti
var egnyteClient = new EgnyteClient("token", "acme", httpClient);

var exception = await AssertExtensions.ThrowsAsync<ArgumentNullException>(
() => 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);
}
}
Expand Down
6 changes: 3 additions & 3 deletions Egnyte.Api.Tests/ProjectFolders/RemoveProjectTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -42,9 +42,9 @@ public async Task RemoveProject_WhenProjectIdIsEmpty_ThrowsArgumentNullException
var egnyteClient = new EgnyteClient("token", "acme", httpClient);

var exception = await AssertExtensions.ThrowsAsync<ArgumentNullException>(
() => 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);
}
}
Expand Down
6 changes: 5 additions & 1 deletion Egnyte.Api.Tests/ProjectFolders/UpdateProjectTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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);
Expand All @@ -58,6 +59,7 @@ public async Task UpdateProject_WhenNameIsEmpty_ThrowsArgumentNullException()
var exception = await AssertExtensions.ThrowsAsync<ArgumentNullException>(
() => egnyteClient.ProjectFolders.UpdateProject(
name: string.Empty,
id: "P123",
status: "pending",
projectId: "ABC123"));

Expand All @@ -74,6 +76,7 @@ public async Task UpdateProject_WhenStatusIsEmpty_ThrowsArgumentNullException()
var exception = await AssertExtensions.ThrowsAsync<ArgumentNullException>(
() => egnyteClient.ProjectFolders.UpdateProject(
name: "Acme Widgets HQ",
id: "P123",
status: string.Empty,
projectId: "ABC123"));

Expand All @@ -90,6 +93,7 @@ public async Task UpdateProject_WhenProjectIdIsEmpty_ThrowsArgumentNullException
var exception = await AssertExtensions.ThrowsAsync<ArgumentNullException>(
() => egnyteClient.ProjectFolders.UpdateProject(
name: "Acme Widgets HQ",
id: "P123",
status: "pending",
projectId: string.Empty));

Expand Down
38 changes: 20 additions & 18 deletions Egnyte.Api/ProjectFolders/ProjectFoldersClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,17 @@ public async Task<bool> MarkFolderAsProject(
/// <summary>
/// Retrieve a project based on its Id
/// </summary>
/// <param name="projectId">Project Id</param>
/// <param name="id">Project Id</param>
/// <returns>Project details</returns>
/// <exception cref="ArgumentNullException"></exception>
public async Task<ProjectDetails> FindProjectById(string projectId)
public async Task<ProjectDetails> 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<ProjectDetails>(httpClient);
Expand Down Expand Up @@ -227,17 +227,17 @@ public async Task<CreateFromTemplateResponse> CreateProjectFromTemplate(
/// <summary>
/// Remove a project
/// </summary>
/// <param name="projectId">Project Id</param>
/// <param name="id">Project Id</param>
/// <returns>True if succeeded, False otherwise</returns>
/// <exception cref="ArgumentNullException"></exception>
public async Task<bool> RemoveProject(string projectId)
public async Task<bool> 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<object>(httpClient);
Expand All @@ -248,8 +248,9 @@ public async Task<bool> RemoveProject(string projectId)
/// <summary>
/// Update existing project
/// </summary>
/// <param name="id">Id of the project</param>
/// <param name="name">The name of the project</param>
/// <param name="projectId">ID of the project</param>
/// <param name="projectId">id</param>
/// <param name="status">Status of the project. Possible values: pending, in-progress, or on-hold</param>
/// <param name="description">Optional. Folder description</param>
/// <param name="customerName">Optional. The customer associated with the project</param>
Expand All @@ -260,6 +261,7 @@ public async Task<bool> RemoveProject(string projectId)
/// <exception cref="ArgumentNullException"></exception>
public async Task<bool> UpdateProject(
string name,
string id,
string projectId,
string status,
string description = null,
Expand All @@ -283,7 +285,7 @@ public async Task<bool> 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(
Expand Down Expand Up @@ -312,24 +314,24 @@ public async Task<bool> UpdateProject(
/// <summary>
/// Clean up a project
/// </summary>
/// <param name="projectId">Project Id</param>
/// <param name="id">Project Id</param>
/// <param name="deleteLinks">If set to true, all existing active links in the project will be deleted</param>
/// <param name="usersToDelete">List of User Ids to be deleted</param>
/// <param name="usersToDisable">List of User Ids to be disabled</param>
/// <returns>True if succeeded</returns>
/// <exception cref="ArgumentNullException"></exception>
public async Task<bool> CleanUpProject(
string projectId,
string id,
bool deleteLinks,
List<long> usersToDelete = null,
List<long> 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(
Expand Down Expand Up @@ -384,7 +386,7 @@ private string MapCreateProjectRequest(
}
if (!string.IsNullOrWhiteSpace(projectId))
{
builder.Append("\"projectId\" : \"" + projectId + "\",");
builder.Append("\"id\" : \"" + projectId + "\",");
}
if (!string.IsNullOrWhiteSpace(customerName))
{
Expand Down

0 comments on commit 30ed3b4

Please sign in to comment.