Skip to content

Commit 225cd7d

Browse files
Merge branch 'main' into bfix/165-create-page-fails
2 parents adbbe14 + 12bc6ab commit 225cd7d

File tree

17 files changed

+194
-14
lines changed

17 files changed

+194
-14
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ var complexFiler = new CompoundFilter(
117117
- [x] Users
118118
- [x] Retrieve a User
119119
- [x] List all users
120+
- [x] Retrieve your token's bot user
120121
- [x] Search
121122

122123
## Contribution Guideline

Src/Notion.Client/Api/ApiEndpoints.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
namespace Notion.Client
1+
using System;
2+
3+
namespace Notion.Client
24
{
35
public static class ApiEndpoints
46
{
@@ -15,6 +17,12 @@ public static class UsersApiUrls
1517
{
1618
public static string Retrieve(string userId) => $"/v1/users/{userId}";
1719
public static string List() => "/v1/users";
20+
21+
/// <summary>
22+
/// Get the <see cref="uri string"/> for retrieve your token's bot user.
23+
/// </summary>
24+
/// <returns>Returns a <see cref="uri string"/> retrieve your token's bot user.</returns>
25+
public static string Me() => "/v1/users/me";
1826
}
1927

2028
public static class BlocksApiUrls

Src/Notion.Client/Api/Users/IUsersClient.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,11 @@ public interface IUsersClient
66
{
77
Task<User> RetrieveAsync(string userId);
88
Task<PaginatedList<User>> ListAsync();
9+
10+
/// <summary>
11+
/// Retrieves the bot User associated with the API token provided in the authorization header.
12+
/// </summary>
13+
/// <returns>User object of type bot having an owner field with information about the person who authorized the integration.</returns>
14+
Task<User> MeAsync();
915
}
1016
}

Src/Notion.Client/Api/Users/UsersClient.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,14 @@ public async Task<PaginatedList<User>> ListAsync()
2121
{
2222
return await _client.GetAsync<PaginatedList<User>>(UsersApiUrls.List());
2323
}
24+
25+
/// <summary>
26+
/// Retrieves the bot User associated with the API token provided in the authorization header.
27+
/// </summary>
28+
/// <returns>User object of type bot having an owner field with information about the person who authorized the integration.</returns>
29+
public async Task<User> MeAsync()
30+
{
31+
return await _client.GetAsync<User>(UsersApiUrls.Me());
32+
}
2433
}
2534
}

Src/Notion.Client/Models/PropertyValue/NumberPropertyValue.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ public class NumberPropertyValue : PropertyValue
1313
/// Value of number
1414
/// </summary>
1515
[JsonProperty("number")]
16-
public double Number { get; set; }
16+
public double? Number { get; set; }
1717
}
1818
}

Src/Notion.Client/Models/PropertyValue/RollupPropertyValue.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class RollupValue
2929
/// Number rollup property values contain a number
3030
/// </summary>
3131
[JsonProperty("number")]
32-
public double Number { get; set; }
32+
public double? Number { get; set; }
3333

3434
/// <summary>
3535
/// Date rollup property values contain a date property value.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using Newtonsoft.Json;
2+
3+
namespace Notion.Client
4+
{
5+
public class Bot
6+
{
7+
[JsonProperty("owner")]
8+
public IBotOwner Owner { get; set; }
9+
}
10+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using JsonSubTypes;
2+
using Newtonsoft.Json;
3+
4+
namespace Notion.Client
5+
{
6+
[JsonConverter(typeof(JsonSubtypes), "type")]
7+
[JsonSubtypes.KnownSubType(typeof(UserOwner), "user")]
8+
[JsonSubtypes.KnownSubType(typeof(WorkspaceIntegrationOwner), "workspace")]
9+
public interface IBotOwner
10+
{
11+
[JsonProperty("type")]
12+
string Type { get; set; }
13+
}
14+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using Newtonsoft.Json;
2+
3+
namespace Notion.Client
4+
{
5+
public class UserOwner : IBotOwner
6+
{
7+
public string Type { get; set; }
8+
9+
[JsonProperty("user")]
10+
public User User { get; set; }
11+
}
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using Newtonsoft.Json;
2+
3+
namespace Notion.Client
4+
{
5+
public class WorkspaceIntegrationOwner : IBotOwner
6+
{
7+
public string Type { get; set; }
8+
9+
[JsonProperty("workspace")]
10+
public bool Workspace { get; set; }
11+
}
12+
}

0 commit comments

Comments
 (0)