Skip to content

Commit 0d12600

Browse files
committed
Version 2.0.4
* Added an ability to get folderless lists.
1 parent b5471fe commit 0d12600

File tree

9 files changed

+405
-2
lines changed

9 files changed

+405
-2
lines changed

Chinchilla.ClickUp.Tests/ClickUpApiTests.cs

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ public void ShouldCreateTeamSpace()
231231
}
232232

233233
/// <summary>
234-
/// Tests of GetSpaceProjects method
234+
/// Tests of ShouldGetSpaceFolders method
235235
/// </summary>
236236
[Test]
237237
public void ShouldGetSpaceFolders()
@@ -340,6 +340,40 @@ public void ShouldCreateList()
340340
}
341341
}
342342

343+
/// <summary>
344+
/// Tests of GetFolderlessLists method
345+
/// </summary>
346+
[Test]
347+
public void ShouldGetFolderlessLists()
348+
{
349+
string methodName = "GetFolderlessLists";
350+
ResponseGeneric<ResponseFolderlessLists, ResponseError> response = null;
351+
try
352+
{
353+
ClickUpApi clickUpAPI = new ClickUpApi(_accessToken);
354+
response = clickUpAPI.GetFolderlessLists(new ParamsGetFolderlessLists(_spaceId));
355+
}
356+
catch (Exception ex)
357+
{
358+
Assert.Fail($"The Test Method of '{methodName}' generate exception: {ex.Message}"); // Always return false
359+
}
360+
if (response != null)
361+
{
362+
Assert.That(response.ResponseSuccess != null || response.ResponseError != null, $"The ResponseSuccess and the ResponseError of the GenericResponse of the request through the method '{methodName}' are null!"); // Always return false
363+
if (response.ResponseError != null)
364+
Assert.Fail($"The Test Method of '{methodName}' generate an error with status: {response.RequestStatus} and response: {response.ResponseError.Err}");
365+
else
366+
{
367+
Assert.That(response.ResponseSuccess.Lists.Any(), $"The Response of the request through the method '{methodName}' did not return any spaces!");
368+
Assert.That(response.ResponseSuccess.Lists.Any(x => x.Name == "Test Folderless List 212 created from Tests"), $"The Response of the request through the method '{methodName}' returned a list without one with an expected name!");
369+
}
370+
}
371+
else
372+
{
373+
Assert.Fail($"The Response of the request through the method '{methodName}' is null!");
374+
}
375+
}
376+
343377
/// <summary>
344378
/// Tests of CreateFolderlessList method
345379
/// </summary>
@@ -851,6 +885,43 @@ public void ShouldCreateListAsync()
851885
}
852886
}
853887

888+
/// <summary>
889+
/// Tests of ShouldGetFolderlessListsAsync method
890+
/// </summary>
891+
[Test]
892+
public void ShouldGetFolderlessListsAsync()
893+
{
894+
string methodName = "GetFolderlessListsAsync";
895+
ResponseGeneric<ResponseFolderlessLists, ResponseError> response = null;
896+
try
897+
{
898+
ClickUpApi clickUpAPI = new ClickUpApi(_accessToken);
899+
Task.Run(async () => {
900+
response = await clickUpAPI.GetFolderlessListsAsync(new ParamsGetFolderlessLists(_spaceId));
901+
})
902+
.Wait();
903+
}
904+
catch (Exception ex)
905+
{
906+
Assert.Fail($"The Test Method of '{methodName}' generate exception: {ex.Message}"); // Always return false
907+
}
908+
if (response != null)
909+
{
910+
Assert.That(response.ResponseSuccess != null || response.ResponseError != null, $"The ResponseSuccess and the ResponseError of the GenericResponse of the request through the method '{methodName}' are null!"); // Always return false
911+
if (response.ResponseError != null)
912+
Assert.Fail($"The Test Method of '{methodName}' generate an error with status: {response.RequestStatus} and response: {response.ResponseError.Err}");
913+
else
914+
{
915+
Assert.That(response.ResponseSuccess.Lists.Any(), $"The Response of the request through the method '{methodName}' did not return any spaces!");
916+
Assert.That(response.ResponseSuccess.Lists.Any(x => x.Name == "Test Folderless List 212 created from Tests"), $"The Response of the request through the method '{methodName}' returned a list without one with an expected name!");
917+
}
918+
}
919+
else
920+
{
921+
Assert.Fail($"The Response of the request through the method '{methodName}' is null!");
922+
}
923+
}
924+
854925
/// <summary>
855926
/// Tests of CreateFolderlessListAsync method
856927
/// </summary>

Chinchilla.ClickUp/Chinchilla.ClickUp.csproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@
1212
<RepositoryType>git</RepositoryType>
1313
<PackageTags>api;csharp;rest;clickup</PackageTags>
1414
<PackageId>Chinchilla.ClickUp</PackageId>
15-
<Version>2.0.3</Version>
15+
<Version>2.0.4</Version>
1616
<PackageReleaseNotes>
17+
Version 2.0.4
18+
19+
* Added an ability to get folderless lists.
20+
1721
Version 2.0.3
1822

1923
* Added an ability to create space folders.

Chinchilla.ClickUp/ClickUpApi.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,22 @@ public ResponseGeneric<ResponseModelList, ResponseError> CreateList(ParamsCreate
207207
return result;
208208
}
209209

210+
/// <summary>
211+
/// Get a space's lists AKA folderless lists
212+
/// </summary>
213+
/// <param name="paramsGetFolderlessLists">param object of get folderless lists request</param>
214+
/// <returns>ResponseGeneric with ResponseFolderlessLists response object</returns>
215+
public ResponseGeneric<ResponseFolderlessLists, ResponseError> GetFolderlessLists(ParamsGetFolderlessLists paramsGetFolderlessLists)
216+
{
217+
var client = new RestClient(_baseAddress);
218+
var request = new RestRequest($"space/{paramsGetFolderlessLists.SpaceId}/list", Method.GET);
219+
request.AddHeader("authorization", _accessToken);
220+
221+
// execute the request
222+
ResponseGeneric<ResponseFolderlessLists, ResponseError> result = RestSharperHelper.ExecuteRequest<ResponseFolderlessLists, ResponseError>(client, request);
223+
return result;
224+
}
225+
210226
/// <summary>
211227
/// Create folderless List
212228
/// </summary>
@@ -434,6 +450,21 @@ public Task<ResponseGeneric<ResponseModelList, ResponseError>> CreateListAsync(P
434450
return RestSharperHelper.ExecuteRequestAsync<ResponseModelList, ResponseError>(client, request);
435451
}
436452

453+
/// <summary>
454+
/// Get a space's lists AKA folderless lists
455+
/// </summary>
456+
/// <param name="paramsGetFolderlessLists">param object of get folderless lists request</param>
457+
/// <returns>ResponseGeneric with ResponseFolderlessLists response object</returns>
458+
public Task<ResponseGeneric<ResponseFolderlessLists, ResponseError>> GetFolderlessListsAsync(ParamsGetFolderlessLists paramsGetFolderlessLists)
459+
{
460+
var client = new RestClient(_baseAddress);
461+
var request = new RestRequest($"space/{paramsGetFolderlessLists.SpaceId}/list", Method.GET);
462+
request.AddHeader("authorization", _accessToken);
463+
464+
// execute the request
465+
return RestSharperHelper.ExecuteRequestAsync<ResponseFolderlessLists, ResponseError>(client, request);
466+
}
467+
437468
/// <summary>
438469
/// Create a folderless List
439470
/// </summary>
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
using Newtonsoft.Json;
2+
using System;
3+
using System.Runtime.Serialization;
4+
5+
namespace Chinchilla.ClickUp.Params
6+
{
7+
8+
/// <summary>
9+
/// The Param object of create folder request
10+
/// </summary>
11+
public class ParamsCreateFolder
12+
{
13+
14+
#region Attributes
15+
16+
/// <summary>
17+
/// The Project Id
18+
/// </summary>
19+
[JsonProperty("space_id")]
20+
[DataMember(Name = "space_id")]
21+
public string SpaceId { get; set; }
22+
23+
#endregion
24+
25+
26+
#region Constructor
27+
28+
/// <summary>
29+
/// The constructor of ParamsCreateList
30+
/// </summary>
31+
/// <param name="spaceId"></param>
32+
public ParamsCreateFolder(string spaceId)
33+
{
34+
SpaceId = spaceId;
35+
}
36+
37+
#endregion
38+
39+
40+
#region Public Methods
41+
42+
/// <summary>
43+
/// Method that validate the data insert
44+
/// </summary>
45+
public void ValidateData()
46+
{
47+
if (string.IsNullOrEmpty(SpaceId))
48+
{
49+
throw new ArgumentNullException("SpaceId");
50+
}
51+
}
52+
53+
#endregion
54+
55+
}
56+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
using Newtonsoft.Json;
2+
using System;
3+
using System.Runtime.Serialization;
4+
5+
namespace Chinchilla.ClickUp.Params
6+
{
7+
8+
/// <summary>
9+
/// The Param object of create list request
10+
/// </summary>
11+
public class ParamsCreateFolderList
12+
{
13+
14+
#region Attributes
15+
16+
/// <summary>
17+
/// The Project Id
18+
/// </summary>
19+
[JsonProperty("folder_id")]
20+
[DataMember(Name = "folder_id")]
21+
public string FolderId { get; set; }
22+
23+
#endregion
24+
25+
26+
#region Constructor
27+
28+
/// <summary>
29+
/// The constructor of ParamsCreateList
30+
/// </summary>
31+
/// <param name="folderId"></param>
32+
public ParamsCreateFolderList(string folderId)
33+
{
34+
FolderId = folderId;
35+
}
36+
37+
#endregion
38+
39+
40+
#region Public Methods
41+
42+
/// <summary>
43+
/// Method that validate the data insert
44+
/// </summary>
45+
public void ValidateData()
46+
{
47+
if (string.IsNullOrEmpty(FolderId))
48+
{
49+
throw new ArgumentNullException("FolderId");
50+
}
51+
}
52+
53+
#endregion
54+
55+
}
56+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
using Newtonsoft.Json;
2+
using System;
3+
using System.Runtime.Serialization;
4+
5+
namespace Chinchilla.ClickUp.Params
6+
{
7+
8+
/// <summary>
9+
/// The Param object of create list request
10+
/// </summary>
11+
public class ParamsCreateFolderlessList
12+
{
13+
14+
#region Attributes
15+
16+
/// <summary>
17+
/// The Project Id
18+
/// </summary>
19+
[JsonProperty("space_id")]
20+
[DataMember(Name = "space_id")]
21+
public string SpaceId { get; set; }
22+
23+
#endregion
24+
25+
26+
#region Constructor
27+
28+
/// <summary>
29+
/// The constructor of ParamsCreateList
30+
/// </summary>
31+
/// <param name="spaceId"></param>
32+
public ParamsCreateFolderlessList(string spaceId)
33+
{
34+
SpaceId = spaceId;
35+
}
36+
37+
#endregion
38+
39+
40+
#region Public Methods
41+
42+
/// <summary>
43+
/// Method that validate the data insert
44+
/// </summary>
45+
public void ValidateData()
46+
{
47+
if (string.IsNullOrEmpty(SpaceId))
48+
{
49+
throw new ArgumentNullException("SpaceId");
50+
}
51+
}
52+
53+
#endregion
54+
55+
}
56+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
using Newtonsoft.Json;
2+
using System;
3+
using System.Runtime.Serialization;
4+
5+
namespace Chinchilla.ClickUp.Params
6+
{
7+
8+
/// <summary>
9+
/// The param object of Get Space lists request
10+
/// </summary>
11+
public class ParamsGetFolderlessLists
12+
{
13+
#region Attributes
14+
15+
/// <summary>
16+
/// The Space Id
17+
/// </summary>
18+
[JsonProperty("space_id")]
19+
[DataMember(Name = "space_id")]
20+
public string SpaceId { get; set; }
21+
22+
#endregion
23+
24+
25+
#region Constructor
26+
27+
/// <summary>
28+
/// The constructor of ParamsGetFolderlessLists
29+
/// </summary>
30+
/// <param name="spaceId"></param>
31+
public ParamsGetFolderlessLists(string spaceId)
32+
{
33+
SpaceId = spaceId;
34+
}
35+
36+
#endregion
37+
38+
39+
#region Public Methods
40+
41+
/// <summary>
42+
/// Method that validate the data insert
43+
/// </summary>
44+
public void ValidateData()
45+
{
46+
if (string.IsNullOrEmpty(SpaceId))
47+
{
48+
throw new ArgumentNullException("SpaceId");
49+
}
50+
}
51+
52+
#endregion
53+
}
54+
}

0 commit comments

Comments
 (0)