Skip to content

Commit 5551629

Browse files
authored
Merge branch 'main' into fix/null-props
2 parents 8fc2848 + a9e8c60 commit 5551629

File tree

134 files changed

+1785
-421
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+1785
-421
lines changed

.github/release-drafter.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
categories:
2+
- title: '🚀 Features'
3+
labels:
4+
- 'feature'
5+
- 'enhancement'
6+
- title: '🐛 Bug Fixes'
7+
labels:
8+
- 'fix'
9+
- 'bugfix'
10+
- 'bug'
11+
- title: '🧰 Maintenance'
12+
label: 'chore'
13+
template: |
14+
## Changes
15+
16+
$CHANGES

.github/workflows/release-drafter.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Release Drafter
2+
3+
on:
4+
push:
5+
# branches to consider in the event; optional, defaults to all
6+
branches:
7+
- main
8+
# pull_request event is required only for autolabeler
9+
pull_request:
10+
# Only following types are handled by the action, but one can default to all as well
11+
types: [opened, reopened, synchronize]
12+
# pull_request_target event is required for autolabeler to support PRs from forks
13+
pull_request_target:
14+
types: [opened, reopened, synchronize]
15+
16+
permissions:
17+
contents: read
18+
19+
jobs:
20+
update_release_draft:
21+
permissions:
22+
# write permission is required to create a github release
23+
contents: write
24+
# write permission is required for autolabeler
25+
# otherwise, read permission is required at least
26+
pull-requests: write
27+
runs-on: ubuntu-latest
28+
steps:
29+
# (Optional) GitHub Enterprise requires GHE_HOST variable set
30+
#- name: Set GHE_HOST
31+
# run: |
32+
# echo "GHE_HOST=${GITHUB_SERVER_URL##https:\/\/}" >> $GITHUB_ENV
33+
34+
# Drafts your next Release notes as Pull Requests are merged into "master"
35+
- uses: release-drafter/[email protected]
36+
# (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml
37+
# with:
38+
# config-name: my-config.yml
39+
# disable-autolabeler: true
40+
env:
41+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Src/Notion.Client/Api/ApiEndpoints.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,5 +131,10 @@ public static string Create()
131131
return "/v1/comments";
132132
}
133133
}
134+
135+
public static class AuthenticationUrls
136+
{
137+
public static string CreateToken() => "/v1/oauth/token";
138+
}
134139
}
135140
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace Notion.Client
2+
{
3+
public sealed partial class AuthenticationClient : IAuthenticationClient
4+
{
5+
private readonly IRestClient _client;
6+
7+
public AuthenticationClient(IRestClient restClient)
8+
{
9+
_client = restClient;
10+
}
11+
}
12+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System.Threading;
2+
using System.Threading.Tasks;
3+
4+
namespace Notion.Client
5+
{
6+
public sealed partial class AuthenticationClient
7+
{
8+
public async Task<CreateTokenResponse> CreateTokenAsync(
9+
CreateTokenRequest createTokenRequest,
10+
CancellationToken cancellationToken = default)
11+
{
12+
var body = (ICreateTokenBodyParameters)createTokenRequest;
13+
14+
return await _client.PostAsync<CreateTokenResponse>(
15+
ApiEndpoints.AuthenticationUrls.CreateToken(),
16+
body,
17+
cancellationToken: cancellationToken
18+
);
19+
}
20+
}
21+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
namespace Notion.Client
2+
{
3+
public class CreateTokenRequest : ICreateTokenBodyParameters
4+
{
5+
public string GrantType => "authorization_code";
6+
7+
public string Code { get; set; }
8+
9+
public string RedirectUri { get; set; }
10+
11+
public ExternalAccount ExternalAccount { get; set; }
12+
}
13+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using Newtonsoft.Json;
2+
3+
namespace Notion.Client
4+
{
5+
/// <summary>
6+
/// External account info
7+
/// </summary>
8+
public class ExternalAccount
9+
{
10+
/// <summary>
11+
/// External account key
12+
/// </summary>
13+
[JsonProperty("key")]
14+
public string Key { get; set; }
15+
16+
/// <summary>
17+
/// External account name
18+
/// </summary>
19+
[JsonProperty("name")]
20+
public string Name { get; set; }
21+
}
22+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using Newtonsoft.Json;
2+
3+
namespace Notion.Client
4+
{
5+
public interface ICreateTokenBodyParameters
6+
{
7+
/// <summary>
8+
/// A constant string: "authorization_code".
9+
/// </summary>
10+
[JsonProperty("grant_type")]
11+
string GrantType { get; }
12+
13+
/// <summary>
14+
/// A unique random code that Notion generates to authenticate with your service,
15+
/// generated when a user initiates the OAuth flow.
16+
/// </summary>
17+
[JsonProperty("code")]
18+
string Code { get; set; }
19+
20+
/// <summary>
21+
/// The "redirect_uri" that was provided in the OAuth Domain & URI section
22+
/// of the integration's Authorization settings. Do not include this field if a
23+
/// "redirect_uri" query param was not included in the Authorization URL
24+
/// provided to users. In most cases, this field is required.
25+
/// </summary>
26+
[JsonProperty("redirect_uri")]
27+
string RedirectUri { get; set; }
28+
29+
/// <summary>
30+
/// External account details
31+
/// </summary>
32+
[JsonProperty("external_account")]
33+
ExternalAccount ExternalAccount { get; set; }
34+
}
35+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using Newtonsoft.Json;
2+
3+
namespace Notion.Client
4+
{
5+
public class CreateTokenResponse
6+
{
7+
[JsonProperty("access_token")]
8+
public string AccessToken { get; set; }
9+
10+
[JsonProperty("token_type")]
11+
public string TokenType { get; set; } = "bearer";
12+
13+
[JsonProperty("bot_id")]
14+
public string BotId { get; set; }
15+
16+
[JsonProperty("duplicated_template_id")]
17+
public string DuplicatedTemplateId { get; set; }
18+
19+
[JsonProperty("owner")]
20+
public IBotOwner Owner { get; set; }
21+
22+
[JsonProperty("workspace_icon")]
23+
public string WorkspaceIcon { get; set; }
24+
25+
[JsonProperty("workspace_id")]
26+
public string WorkspaceId { get; set; }
27+
28+
[JsonProperty("workspace_name")]
29+
public string WorkspaceName { get; set; }
30+
}
31+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System.Threading;
2+
using System.Threading.Tasks;
3+
4+
namespace Notion.Client
5+
{
6+
/// <summary>
7+
/// Authentication client
8+
/// </summary>
9+
public interface IAuthenticationClient
10+
{
11+
/// <summary>
12+
/// Creates an access token that a third-party service can use to authenticate with Notion.
13+
/// </summary>
14+
/// <param name="createTokenRequest"></param>
15+
/// <param name="cancellationToken"></param>
16+
/// <returns></returns>
17+
Task<CreateTokenResponse> CreateTokenAsync(
18+
CreateTokenRequest createTokenRequest,
19+
CancellationToken cancellationToken = default
20+
);
21+
}
22+
}

0 commit comments

Comments
 (0)