File tree Expand file tree Collapse file tree 12 files changed +137
-2
lines changed Expand file tree Collapse file tree 12 files changed +137
-2
lines changed Original file line number Diff line number Diff line change @@ -61,5 +61,10 @@ public static class SearchApiUrls
6161 {
6262 public static string Search ( ) => "/v1/search" ;
6363 }
64+
65+ public static class CommentsApiUrls
66+ {
67+ public static string Retrieve ( ) => "/v1/comments" ;
68+ }
6469 }
6570}
Original file line number Diff line number Diff line change 1+ namespace Notion . Client
2+ {
3+ public partial class CommentsClient : ICommentsClient
4+ {
5+ private readonly IRestClient _client ;
6+
7+ public CommentsClient ( IRestClient restClient )
8+ {
9+ _client = restClient ;
10+ }
11+ }
12+ }
Original file line number Diff line number Diff line change 1+ using System . Threading . Tasks ;
2+
3+ namespace Notion . Client
4+ {
5+ public interface ICommentsClient
6+ {
7+ /// <summary>
8+ /// Retrieves a list of un-resolved Comment objects from a page or block.
9+ /// </summary>
10+ /// <param name="retrieveCommentsParameters">Retrieve comments parameters</param>
11+ /// <returns><see cref="RetrieveCommentsResponse"/></returns>
12+ Task < RetrieveCommentsResponse > Retrieve ( RetrieveCommentsParameters retrieveCommentsParameters ) ;
13+ }
14+ }
Original file line number Diff line number Diff line change 1+ using System . Collections . Generic ;
2+ using System . Threading . Tasks ;
3+
4+ namespace Notion . Client
5+ {
6+ public partial class CommentsClient
7+ {
8+ public async Task < RetrieveCommentsResponse > Retrieve ( RetrieveCommentsParameters parameters )
9+ {
10+ var qp = ( IRetrieveCommentsQueryParameters ) parameters ;
11+
12+ var queryParams = new Dictionary < string , string > ( )
13+ {
14+ { "block_id" , qp . BlockId } ,
15+ { "start_cursor" , qp . StartCursor } ,
16+ { "page_size" , qp . PageSize . ToString ( ) } ,
17+ } ;
18+
19+ return await _client . GetAsync < RetrieveCommentsResponse > (
20+ ApiEndpoints . CommentsApiUrls . Retrieve ( ) ,
21+ queryParams
22+ ) ;
23+ }
24+ }
25+ }
Original file line number Diff line number Diff line change 1+ using Newtonsoft . Json ;
2+
3+ namespace Notion . Client
4+ {
5+ public interface IRetrieveCommentsQueryParameters : IPaginationParameters
6+ {
7+ [ JsonProperty ( "block_id" ) ]
8+ string BlockId { get ; set ; }
9+ }
10+ }
Original file line number Diff line number Diff line change 1+ namespace Notion . Client
2+ {
3+ public class RetrieveCommentsParameters : IRetrieveCommentsQueryParameters
4+ {
5+ public string BlockId { get ; set ; }
6+ public string StartCursor { get ; set ; }
7+ public int ? PageSize { get ; set ; }
8+ }
9+ }
Original file line number Diff line number Diff line change 1+ using System ;
2+ using System . Collections . Generic ;
3+ using Newtonsoft . Json ;
4+
5+ namespace Notion . Client
6+ {
7+ public class Comment : IObject
8+ {
9+ public string Id { get ; set ; }
10+
11+ public ObjectType Object => ObjectType . Comment ;
12+
13+ [ JsonProperty ( "parent" ) ]
14+ public ICommentParent Parent { get ; set ; }
15+
16+ [ JsonProperty ( "discussion_id" ) ]
17+ public string DiscussionId { get ; set ; }
18+
19+ [ JsonProperty ( "rich_text" ) ]
20+ public IEnumerable < RichTextBase > RichText { get ; set ; }
21+
22+ [ JsonProperty ( "created_by" ) ]
23+ public PartialUser CreatedBy { get ; set ; }
24+
25+ [ JsonProperty ( "created_time" ) ]
26+ public DateTime CreatedTime { get ; set ; }
27+
28+ [ JsonProperty ( "last_edited_time" ) ]
29+ public DateTime LastEditedTime { get ; set ; }
30+ }
31+ }
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 class RetrieveCommentsResponse : PaginatedList < Comment >
7+ {
8+ [ JsonProperty ( "type" ) ]
9+ public string Type { get ; set ; }
10+
11+ [ JsonProperty ( "comment" ) ]
12+ public Dictionary < string , object > Comment { get ; set ; }
13+ }
14+ }
Original file line number Diff line number Diff line change 1+ using JsonSubTypes ;
2+ using Newtonsoft . Json ;
3+
4+ namespace Notion . Client
5+ {
6+ [ JsonConverter ( typeof ( JsonSubtypes ) , "type" ) ]
7+ [ JsonSubtypes . KnownSubType ( typeof ( PageParent ) , ParentType . PageId ) ]
8+ [ JsonSubtypes . KnownSubType ( typeof ( BlockParent ) , ParentType . BlockId ) ]
9+ public interface ICommentParent
10+ {
11+ }
12+ }
Original file line number Diff line number Diff line change @@ -15,5 +15,8 @@ public enum ObjectType
1515
1616 [ EnumMember ( Value = "user" ) ]
1717 User ,
18+
19+ [ EnumMember ( Value = "comment" ) ]
20+ Comment ,
1821 }
1922}
You can’t perform that action at this time.
0 commit comments