Skip to content

Commit 0f32f64

Browse files
add support for retrieve database API ✨
1 parent 8755042 commit 0f32f64

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

Src/Notion.Client/DatabaseClient.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
using System;
12
using System.Collections.Generic;
23
using System.Threading.Tasks;
34

45
namespace Notion.Client
56
{
67
public interface IDatabaseClient
78
{
9+
Task<Database> RetrieveAsync(string databaseId);
810
Task<PaginatedList<Database>> ListAsync(DatabasesListParameters databasesListParameters = null);
911
}
1012

@@ -17,6 +19,19 @@ public DatabaseClient(IRestClient client)
1719
_client = client;
1820
}
1921

22+
public async Task<Database> RetrieveAsync(string databaseId)
23+
{
24+
try
25+
{
26+
return await _client.GetAsync<Database>($"databases/{databaseId}");
27+
}
28+
catch (Exception e)
29+
{
30+
// Todo: Throw Custom Exception
31+
return null;
32+
}
33+
}
34+
2035
public async Task<PaginatedList<Database>> ListAsync(DatabasesListParameters databasesListParameters = null)
2136
{
2237
try
@@ -29,7 +44,7 @@ public async Task<PaginatedList<Database>> ListAsync(DatabasesListParameters dat
2944

3045
return await _client.GetAsync<PaginatedList<Database>>("databases", queryParams);
3146
}
32-
catch (System.Exception e)
47+
catch (Exception e)
3348
{
3449
// Todo: Throw Custom Exception
3550
return null;

Test/Notion.UnitTests/DatabasesClientTests.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,13 @@ public async Task ListDatabasesAsync()
2424
var databasesList = await _client.ListAsync();
2525
Assert.NotNull(databasesList);
2626
}
27+
28+
[Fact(Skip = "Internal Testing Purpose")]
29+
public async Task RetrieveDatabaseAsync()
30+
{
31+
var databaseId = "";
32+
var database = await _client.RetrieveAsync(databaseId);
33+
Assert.NotNull(database);
34+
}
2735
}
2836
}

0 commit comments

Comments
 (0)