22
33namespace FiveamCode \LaravelNotionApi \Endpoints ;
44
5- use FiveamCode \LaravelNotionApi \Exceptions \NotionException ;
6- use FiveamCode \LaravelNotionApi \Query \StartCursor ;
7- use Illuminate \Support \Collection ;
5+ use Illuminate \Http \Client \Response ;
86use FiveamCode \LaravelNotionApi \Notion ;
7+ use GuzzleHttp \Promise \PromiseInterface ;
8+ use FiveamCode \LaravelNotionApi \Query \StartCursor ;
9+ use FiveamCode \LaravelNotionApi \Exceptions \NotionException ;
910use FiveamCode \LaravelNotionApi \Exceptions \HandlingException ;
11+ use FiveamCode \LaravelNotionApi \Exceptions \LaravelNotionAPIException ;
1012
1113class Endpoint
1214{
@@ -22,8 +24,14 @@ class Endpoint
2224 protected ?StartCursor $ startCursor = null ;
2325 protected int $ pageSize = 100 ;
2426
25- protected ?\ Illuminate \ Http \ Client \ Response $ response = null ;
27+ protected ?Response $ response = null ;
2628
29+ /**
30+ * Endpoint constructor.
31+ * @param Notion $notion
32+ * @throws HandlingException
33+ * @throws LaravelNotionAPIException
34+ */
2735 public function __construct (Notion $ notion )
2836 {
2937 $ this ->notion = $ notion ;
@@ -49,6 +57,7 @@ protected function url(string $endpoint): string
4957 *
5058 * @param string $url
5159 * @return array
60+ * @throws NotionException|HandlingException
5261 */
5362 protected function getJson (string $ url ): array
5463 {
@@ -59,7 +68,9 @@ protected function getJson(string $url): array
5968 }
6069
6170 /**
62- *
71+ * @param string $url
72+ * @throws HandlingException
73+ * @throws NotionException
6374 */
6475 protected function get (string $ url )
6576 {
@@ -72,14 +83,19 @@ protected function get(string $url)
7283 }
7384
7485 /**
75- *
86+ * @param string $url
87+ * @param array $body
88+ * @return PromiseInterface|Response
7689 */
7790 protected function post (string $ url , array $ body )
7891 {
7992 return $ this ->notion ->getConnection ()->post ($ url , $ body );
8093 }
8194
8295
96+ /**
97+ * @return string
98+ */
8399 protected function buildPaginationQuery (): string
84100 {
85101 $ paginationQuery = "" ;
@@ -93,20 +109,27 @@ protected function buildPaginationQuery(): string
93109 return $ paginationQuery ;
94110 }
95111
112+ /**
113+ * @param int $limit
114+ * @return $this
115+ */
96116 public function limit (int $ limit ): Endpoint
97117 {
98118 $ this ->pageSize = min ($ limit , 100 );
99119
100120 return $ this ;
101121 }
102122
123+ /**
124+ * @param StartCursor $startCursor
125+ * @return Endpoint
126+ * @throws HandlingException
127+ * @throws LaravelNotionAPIException
128+ */
103129 public function offset (StartCursor $ startCursor ): Endpoint
104130 {
105131 // toDo
106132 throw HandlingException::instance ("Not implemented yet. " );
107-
108- $ this ->startCursor = $ startCursor ;
109- return $ this ;
110133 }
111134
112135}
0 commit comments