11using System ;
22using System . Collections . Generic ;
33using System . Diagnostics . CodeAnalysis ;
4+ using System . Threading ;
45using System . Threading . Tasks ;
56using static Notion . Client . ApiEndpoints ;
67
@@ -25,7 +26,7 @@ public PagesClient(IRestClient client)
2526 /// </summary>
2627 /// <param name="pagesCreateParameters">Create page parameters</param>
2728 /// <returns>Created page.</returns>
28- public async Task < Page > CreateAsync ( PagesCreateParameters pagesCreateParameters )
29+ public async Task < Page > CreateAsync ( PagesCreateParameters pagesCreateParameters , CancellationToken cancellationToken = default )
2930 {
3031 if ( pagesCreateParameters is null )
3132 {
@@ -44,18 +45,18 @@ public async Task<Page> CreateAsync(PagesCreateParameters pagesCreateParameters)
4445 throw new ArgumentNullException ( nameof ( bodyParameters . Properties ) , "Properties are required!" ) ;
4546 }
4647
47- return await _client . PostAsync < Page > ( PagesApiUrls . Create ( ) , bodyParameters ) ;
48+ return await _client . PostAsync < Page > ( PagesApiUrls . Create ( ) , bodyParameters , cancellationToken : cancellationToken ) ;
4849 }
4950
50- public async Task < Page > RetrieveAsync ( string pageId )
51+ public async Task < Page > RetrieveAsync ( string pageId , CancellationToken cancellationToken = default )
5152 {
5253 var url = PagesApiUrls . Retrieve ( pageId ) ;
5354
54- return await _client . GetAsync < Page > ( url ) ;
55+ return await _client . GetAsync < Page > ( url , cancellationToken : cancellationToken ) ;
5556 }
5657
5758 public async Task < IPropertyItemObject > RetrievePagePropertyItemAsync (
58- RetrievePropertyItemParameters retrievePropertyItemParameters )
59+ RetrievePropertyItemParameters retrievePropertyItemParameters , CancellationToken cancellationToken = default )
5960 {
6061 var pathParameters = ( IRetrievePropertyItemPathParameters ) retrievePropertyItemParameters ;
6162 var queryParameters = ( IRetrievePropertyQueryParameters ) retrievePropertyItemParameters ;
@@ -68,27 +69,27 @@ public async Task<IPropertyItemObject> RetrievePagePropertyItemAsync(
6869 { "page_size" , queryParameters ? . PageSize ? . ToString ( ) }
6970 } ;
7071
71- return await _client . GetAsync < IPropertyItemObject > ( url , queryParams ) ;
72+ return await _client . GetAsync < IPropertyItemObject > ( url , queryParams , cancellationToken : cancellationToken ) ;
7273 }
7374
74- public async Task < Page > UpdateAsync ( string pageId , PagesUpdateParameters pagesUpdateParameters )
75+ public async Task < Page > UpdateAsync ( string pageId , PagesUpdateParameters pagesUpdateParameters , CancellationToken cancellationToken = default )
7576 {
7677 var url = PagesApiUrls . Update ( pageId ) ;
7778 var body = ( IPagesUpdateBodyParameters ) pagesUpdateParameters ;
7879
79- return await _client . PatchAsync < Page > ( url , body ) ;
80+ return await _client . PatchAsync < Page > ( url , body , cancellationToken : cancellationToken ) ;
8081 }
8182
8283 [ Obsolete ( "This method is obsolete. Use UpdateAsync instead. This API will be removed in future release" ) ]
8384 public async Task < Page > UpdatePropertiesAsync (
8485 string pageId ,
85- IDictionary < string , PropertyValue > updatedProperties )
86+ IDictionary < string , PropertyValue > updatedProperties , CancellationToken cancellationToken = default )
8687 {
8788 var url = PagesApiUrls . UpdateProperties ( pageId ) ;
8889
8990 var body = new UpdatePropertiesParameters { Properties = updatedProperties } ;
9091
91- return await _client . PatchAsync < Page > ( url , body ) ;
92+ return await _client . PatchAsync < Page > ( url , body , cancellationToken : cancellationToken ) ;
9293 }
9394
9495 [ SuppressMessage ( "ReSharper" , "UnusedAutoPropertyAccessor.Local" ) ]
0 commit comments