1212class Database extends Entity
1313{
1414 private string $ title = "" ;
15- private array $ rawTitle = []; // toDo why "raw"title?
15+ private array $ rawTitle = [];
1616 private array $ rawProperties = [];
1717 private DateTime $ createdTime ;
1818 private DateTime $ lastEditedTime ;
1919
20- // toDo Draft
21- private array $ responseData ;
2220
23-
24- protected function setRaw (array $ raw ): void
21+ protected function setResponseData (array $ responseData ): void
2522 {
26- parent ::setRaw ($ raw );
27- if ($ raw ['object ' ] !== 'database ' ) throw WrapperException::instance ("invalid json-array: the given object is not a database " );
28-
29- //toDo Draft
30- $ this ->responseData = $ raw ;
31-
23+ parent ::setResponseData ($ responseData );
24+ if ($ responseData ['object ' ] !== 'database ' ) throw WrapperException::instance ("invalid json-array: the given object is not a database " );
3225 $ this ->fillFromRaw ();
33-
34- // if (Arr::exists($raw, 'title') && is_array($raw['title'])) {
35- // $this->title = Arr::first($raw['title'], null, ['plain_text' => ''])['plain_text'];
36- // $this->rawTitle = $raw['title'];
37- // }
38- //
39- // if (Arr::exists($raw, 'properties')) {
40- // $this->rawProperties = $raw['properties'];
41- // }
42- //
43- // if (Arr::exists($raw, 'created_time')) {
44- // $this->createdTime = new Carbon($raw['created_time']);
45- // }
46- //
47- // if (Arr::exists($raw, 'last_edited_time')) {
48- // $this->lastEditedTime = new Carbon($raw['last_edited_time']);
49- // }
5026 }
51- //toDo Draft
27+
5228
5329 private function fillFromRaw ()
5430 {
31+ $ this ->fillId ();
5532 $ this ->fillTitle ();
33+ $ this ->fillProperties ();
34+ $ this ->fillCreatedTime ();
35+ $ this ->fillLastEditedTime ();
5636 }
5737
5838 private function fillTitle ()
@@ -62,7 +42,28 @@ private function fillTitle()
6242 $ this ->rawTitle = $ this ->responseData ['title ' ];
6343 }
6444 }
65- //toDo end Draft
45+
46+ private function fillProperties ()
47+ {
48+ if (Arr::exists ($ this ->responseData , 'properties ' )) {
49+ $ this ->rawProperties = $ this ->responseData ['properties ' ];
50+ }
51+ }
52+
53+ private function fillCreatedTime ()
54+ {
55+ if (Arr::exists ($ this ->responseData , 'created_time ' )) {
56+ $ this ->createdTime = new Carbon ($ this ->responseData ['created_time ' ]);
57+ }
58+ }
59+
60+ private function fillLastEditedTime ()
61+ {
62+ if (Arr::exists ($ this ->responseData , 'last_edited_time ' )) {
63+ $ this ->lastEditedTime = new Carbon ($ this ->responseData ['last_edited_time ' ]);
64+ }
65+ }
66+
6667
6768 public function getTitle (): string
6869 {
0 commit comments