-
-
Notifications
You must be signed in to change notification settings - Fork 52
implement notion block types as classes #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
johguentner
commented
Jun 26, 2021
- add easy content and text access for rich-text- (all supported blocks, exept page-blocks) and child-page-blocks
- add fromResponse- and mapTypeToClass-method to Block::class (similar to the implementations within Property::class)
- add easy content and text access for rich-text- (all supported blocks, exept page-blocks) and child-page-blocks - add fromResponse- and mapTypeToClass-method to Block::class (similar to the implementations within Property::class)
check if correct instance is added to collection (depending on block type) check if content of blocks is correctly retreived
src/Entities/Blocks/Block.php
Outdated
$class = str_replace('_', '', ucwords($type, '_')); | ||
return "FiveamCode\\LaravelNotionApi\\Entities\\Blocks\\" . $class; | ||
case 'heading_1': | ||
return "FiveamCode\\LaravelNotionApi\\Entities\\Blocks\\HeadingOne"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HeadingOne::class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ done
@@ -12,11 +12,40 @@ | |||
*/ | |||
class BlockCollection extends EntityCollection | |||
{ | |||
private bool $showUnsupported = false; | |||
|
|||
public function withUnsupported(): BlockCollection |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO-Di: Add PhpDoc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ done
return $collection; | ||
} else { | ||
return $collection->filter(function($block){ | ||
return $block->getType() != 'unsupported'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe !== here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ done
|
||
public function asCollection(): Collection | ||
{ | ||
$collection =parent::asCollection(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
space :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ done
@@ -124,7 +124,7 @@ public function asCollection(): Collection | |||
*/ | |||
public function asJson(): string | |||
{ | |||
return $this->collection->map(function (Entity $item) { | |||
return $this->asCollection()->map(function (Entity $item) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Document this in the Changelog, it's not really breaking but somehow... changed 🤔
Http::fake([ | ||
'https://api.notion.com/v1/blocks/1d719dd1-563b-4387-b74f-20da92b827fb/children*' | ||
=> Http::response( | ||
json_decode(file_get_contents('tests/stubs/endpoints/blocks/response_specific_supported_blocks_200.json'), true), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check indentation to be sure
- for HeadingOne, HeadingTwo and HeadingThree
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
applied all necessary changes
src/Entities/Blocks/Block.php
Outdated
$class = str_replace('_', '', ucwords($type, '_')); | ||
return "FiveamCode\\LaravelNotionApi\\Entities\\Blocks\\" . $class; | ||
case 'heading_1': | ||
return "FiveamCode\\LaravelNotionApi\\Entities\\Blocks\\HeadingOne"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ done
@@ -12,11 +12,40 @@ | |||
*/ | |||
class BlockCollection extends EntityCollection | |||
{ | |||
private bool $showUnsupported = false; | |||
|
|||
public function withUnsupported(): BlockCollection |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ done
|
||
public function asCollection(): Collection | ||
{ | ||
$collection =parent::asCollection(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ done
return $collection; | ||
} else { | ||
return $collection->filter(function($block){ | ||
return $block->getType() != 'unsupported'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
checked