File tree Expand file tree Collapse file tree 5 files changed +75
-0
lines changed Expand file tree Collapse file tree 5 files changed +75
-0
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,8 @@ public static class SearchApiUrls
6565 public static class CommentsApiUrls
6666 {
6767 public static string Retrieve ( ) => "/v1/comments" ;
68+
69+ public static string Create ( ) => "/v1/comments" ;
6870 }
6971 }
7072}
Original file line number Diff line number Diff line change 1+ using System . Threading . Tasks ;
2+
3+ namespace Notion . Client
4+ {
5+ public partial class CommentsClient
6+ {
7+ public async Task < CreateCommentResponse > Create ( CreateCommentParameters parameters )
8+ {
9+ var body = ( ICreateCommentsBodyParameters ) parameters ;
10+
11+ return await _client . PostAsync < CreateCommentResponse > (
12+ ApiEndpoints . CommentsApiUrls . Create ( ) ,
13+ body
14+ ) ;
15+ }
16+ }
17+ }
Original file line number Diff line number Diff line change 1+ using System . Collections . Generic ;
2+ using Newtonsoft . Json ;
3+
4+ namespace Notion . Client
5+ {
6+ public interface ICreateCommentsBodyParameters
7+ {
8+ [ JsonProperty ( "rich_text" ) ]
9+ public IEnumerable < RichTextBaseInput > RichText { get ; set ; }
10+ }
11+
12+ public interface ICreateDiscussionCommentBodyParameters : ICreateCommentsBodyParameters
13+ {
14+ [ JsonProperty ( "discussion_id" ) ]
15+ public string DiscussionId { get ; set ; }
16+ }
17+
18+ public interface ICreatePageCommentBodyParameters : ICreateCommentsBodyParameters
19+ {
20+ [ JsonProperty ( "parent" ) ]
21+ public ParentPageInput Parent { get ; set ; }
22+ }
23+
24+ public class CreateCommentParameters : ICreateDiscussionCommentBodyParameters , ICreatePageCommentBodyParameters
25+ {
26+ public string DiscussionId { get ; set ; }
27+ public IEnumerable < RichTextBaseInput > RichText { get ; set ; }
28+ public ParentPageInput Parent { get ; set ; }
29+
30+ public static CreateCommentParameters CreatePageComment ( ParentPageInput parent , IEnumerable < RichTextBaseInput > richText )
31+ {
32+ return new CreateCommentParameters
33+ {
34+ Parent = parent ,
35+ RichText = richText
36+ } ;
37+ }
38+
39+ public static CreateCommentParameters CreateDiscussionComment ( string discussionId , IEnumerable < RichTextBaseInput > richText )
40+ {
41+ return new CreateCommentParameters
42+ {
43+ DiscussionId = discussionId ,
44+ RichText = richText
45+ } ;
46+ }
47+ }
48+ }
Original file line number Diff line number Diff line change 1+ namespace Notion . Client
2+ {
3+ public class CreateCommentResponse : Comment
4+ {
5+ }
6+ }
Original file line number Diff line number Diff line change @@ -10,5 +10,7 @@ public interface ICommentsClient
1010 /// <param name="retrieveCommentsParameters">Retrieve comments parameters</param>
1111 /// <returns><see cref="RetrieveCommentsResponse"/></returns>
1212 Task < RetrieveCommentsResponse > Retrieve ( RetrieveCommentsParameters retrieveCommentsParameters ) ;
13+
14+ Task < CreateCommentResponse > Create ( CreateCommentParameters createCommentParameters ) ;
1315 }
1416}
You can’t perform that action at this time.
0 commit comments