File tree Expand file tree Collapse file tree 6 files changed +46
-14
lines changed Expand file tree Collapse file tree 6 files changed +46
-14
lines changed Original file line number Diff line number Diff line change 2
2
3
3
namespace FiveamCode \LaravelNotionApi \Endpoints ;
4
4
5
+ use FiveamCode \LaravelNotionApi \Exceptions \HandlingException ;
5
6
use FiveamCode \LaravelNotionApi \Notion ;
6
7
use FiveamCode \LaravelNotionApi \Exceptions \NotionException ;
7
8
use FiveamCode \LaravelNotionApi \Entities \Collections \BlockCollection ;
@@ -29,15 +30,11 @@ public function children(): BlockCollection
29
30
$ this ->url (Endpoint::BLOCKS . "/ " . $ this ->blockId . "/children " . "? {$ this ->buildPaginationQuery ()}" )
30
31
);
31
32
32
- if ($ response ->failed ())
33
- throw NotionException::fromResponse ($ response );
34
-
35
33
return new BlockCollection ($ response ->json ());
36
34
}
37
35
38
36
public function create (): array
39
37
{
40
- //toDo
41
- throw new \Exception ("not implemented yet " );
38
+ throw new HandlingException ("Not implemented " );
42
39
}
43
40
}
Original file line number Diff line number Diff line change 3
3
namespace FiveamCode \LaravelNotionApi \Endpoints ;
4
4
5
5
use FiveamCode \LaravelNotionApi \Entities \Page ;
6
+ use FiveamCode \LaravelNotionApi \Exceptions \HandlingException ;
6
7
use FiveamCode \LaravelNotionApi \Exceptions \NotionException ;
7
8
8
9
class Pages extends Endpoint implements EndpointInterface
@@ -22,22 +23,19 @@ public function find(string $pageId): Page
22
23
$ this ->url (Endpoint::PAGES . "/ " . $ pageId )
23
24
);
24
25
25
- if ($ response ->failed ())
26
- throw NotionException::fromResponse ($ response );
27
-
28
26
return new Page ($ response ->json ());
29
27
}
30
28
31
29
public function create (): array
32
30
{
33
31
//toDo
34
- throw new \ Exception ( " not implemented yet " );
32
+ throw new HandlingException ( " Not implemented " );
35
33
}
36
34
37
35
38
36
public function updateProperties (): array
39
37
{
40
38
//toDo
41
- throw new \ Exception ( " not implemented yet " );
39
+ throw new HandlingException ( " Not implemented " );
42
40
}
43
41
}
Original file line number Diff line number Diff line change @@ -38,10 +38,6 @@ public function find(string $userId): User
38
38
$ this ->url (Endpoint::USERS . "/ " . $ userId )
39
39
);
40
40
41
- if ($ response ->failed ())
42
- throw NotionException::fromResponse ($ response );
43
-
44
-
45
41
return new User ($ response ->json ());
46
42
}
47
43
}
Original file line number Diff line number Diff line change 2
2
3
3
namespace FiveamCode \LaravelNotionApi \Tests ;
4
4
5
+ use FiveamCode \LaravelNotionApi \Exceptions \HandlingException ;
5
6
use Illuminate \Support \Facades \Http ;
6
7
use FiveamCode \LaravelNotionApi \Entities \Blocks \Block ;
7
8
use FiveamCode \LaravelNotionApi \Exceptions \NotionException ;
@@ -88,4 +89,13 @@ public function it_throws_a_notion_exception_not_found()
88
89
\Notion::block ("b55c9c91-384d-452b-81db-d1ef79372b11 " )->children ();
89
90
}
90
91
92
+ /** @test */
93
+ public function it_throws_a_handling_exception_not_implemented () {
94
+
95
+ $ this ->expectException (HandlingException::class);
96
+ $ this ->expectExceptionMessage ("Not implemented " );
97
+
98
+ \Notion::block ("" )->create ();
99
+ }
100
+
91
101
}
Original file line number Diff line number Diff line change 4
4
5
5
use Carbon \Carbon ;
6
6
use FiveamCode \LaravelNotionApi \Entities \Page ;
7
+ use FiveamCode \LaravelNotionApi \Exceptions \HandlingException ;
7
8
use FiveamCode \LaravelNotionApi \Exceptions \NotionException ;
8
9
use Illuminate \Support \Facades \Http ;
9
10
use Orchestra \Testbench \TestCase ;
@@ -86,4 +87,23 @@ public function it_throws_a_notion_exception_not_found()
86
87
\Notion::pages ()->find ("b55c9c91-384d-452b-81db-d1ef79372b79 " );
87
88
}
88
89
90
+
91
+ /** @test */
92
+ public function it_throws_a_handling_exception_not_implemented_for_create () {
93
+
94
+ $ this ->expectException (HandlingException::class);
95
+ $ this ->expectExceptionMessage ("Not implemented " );
96
+
97
+ \Notion::pages ()->create ();
98
+ }
99
+
100
+ /** @test */
101
+ public function it_throws_a_handling_exception_not_implemented_for_update_properties () {
102
+
103
+ $ this ->expectException (HandlingException::class);
104
+ $ this ->expectExceptionMessage ("Not implemented " );
105
+
106
+ \Notion::pages ()->updateProperties ();
107
+ }
108
+
89
109
}
Original file line number Diff line number Diff line change 2
2
3
3
namespace FiveamCode \LaravelNotionApi \Tests ;
4
4
5
+ use FiveamCode \LaravelNotionApi \Exceptions \HandlingException ;
5
6
use FiveamCode \LaravelNotionApi \Notion ;
6
7
use Orchestra \Testbench \TestCase ;
7
8
@@ -37,4 +38,14 @@ public function it_returns_notion_instance_with_set_token_and_connection()
37
38
$ this ->assertInstanceOf (Notion::class, $ notion );
38
39
$ this ->assertNotEmpty ($ notion ->getConnection ());
39
40
}
41
+
42
+
43
+ /** @test */
44
+ public function it_throws_a_handling_exception_invalid_version ()
45
+ {
46
+ $ this ->expectException (HandlingException::class);
47
+ $ this ->expectExceptionMessage ("invalid version for notion-api " );
48
+
49
+ $ notion = new Notion ("secret_* " , "v-does-not-exist " );
50
+ }
40
51
}
You can’t perform that action at this time.
0 commit comments