22
33namespace FiveamCode \LaravelNotionApi \Endpoints ;
44
5+ use FiveamCode \LaravelNotionApi \Query \StartCursor ;
56use Illuminate \Support \Collection ;
67use FiveamCode \LaravelNotionApi \Notion ;
78use FiveamCode \LaravelNotionApi \Exceptions \WrapperException ;
@@ -18,6 +19,10 @@ class Endpoint
1819 public Notion $ notion ;
1920 private Collection $ validVersions ;
2021
22+
23+ protected ?StartCursor $ startCursor = null ;
24+ protected ?int $ pageSize = null ;
25+
2126 public function __construct (Notion $ notion )
2227 {
2328 $ this ->validVersions = collect (["v1 " ]);
@@ -74,4 +79,34 @@ protected function post(string $url, array $body)
7479 return $ this ->notion ->getConnection ()->post ($ url , $ body );
7580 }
7681
82+
83+ protected function buildPaginationQuery (): string
84+ {
85+ $ paginationQuery = "" ;
86+
87+ if ($ this ->pageSize !== null )
88+ $ paginationQuery = "page_size= {$ this ->pageSize }& " ;
89+
90+ if ($ this ->startCursor !== null )
91+ $ paginationQuery .= "start_cursor= {$ this ->startCursor }" ;
92+
93+ return $ paginationQuery ;
94+ }
95+
96+ public function limit (int $ limit ): Endpoint
97+ {
98+ $ this ->pageSize = min ($ limit , 100 );
99+
100+ return $ this ;
101+ }
102+
103+ public function offset (StartCursor $ startCursor ): Endpoint
104+ {
105+ // toDo
106+ throw WrapperException::instance ("Not implemented yet. " );
107+
108+ $ this ->startCursor = $ startCursor ;
109+ return $ this ;
110+ }
111+
77112}
0 commit comments