Coder Social home page Coder Social logo

mariosimao / notion-sdk-php Goto Github PK

View Code? Open in Web Editor NEW
138.0 5.0 24.0 12.66 MB

A complete Notion SDK for PHP developers.

Home Page: https://mariosimao.github.io/notion-sdk-php/

License: MIT License

PHP 100.00%
php notion-api notion sdk hacktoberfest notion-sdk notion-sdk-php notion-client

notion-sdk-php's People

Contributors

aknevrnky avatar awilum avatar braumye avatar champsupertramp avatar dependabot[bot] avatar djafari avatar ffirmenich avatar frederichoule avatar github-actions[bot] avatar iamalexchip avatar joseph-azzam avatar juampi92 avatar larowka avatar mariosimao avatar nfarrington avatar notfloran avatar philippe-pixieset avatar ren0v avatar samzzi avatar tambait avatar willgibson avatar xynnn avatar youvalteboul avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

notion-sdk-php's Issues

How to change the value of a property in a database row?

Hello, tell me what is the correct way to change the value of a property in a row from a database table? And yet, you can show an example of how to add new rows to a table with a data base.

There are no examples at all of how to change property values in pages. Or I didn't find it.

Thanks a lot. I hope you have some time to answer this question.

And thanks a lot for this SDK.

Use `list<Type>` instead of `Type[]`

Instead of using Type[] syntax, consider being explicit about the shape of the input.

For example:

  • RichText[] means array<array-key, RichText>
  • array<int, RichText> could be [0 => new RichText(), 4 => new RichText()]
  • list<RichText> is like array<int, RichText>, but prevents gaps in array keys (safer, when considering that a lot of this stuff will be json_encode()d

Originally posted by @Ocramius in #6 (comment)

Database actions

Support database actions:

  • Create a database
  • Update a database
  • Retrieve a database

Internal cover image is not supported

Internal cover images are now supported by Notion API, as read-only fields. I think we should be able to retrieve pages with internal covers instead of throwing an exception.

Add mutation tests

One thing you may want to start doing instead of coverage, is mutation testing, with either of:

  • infection/infection
  • roave/infection-static-analysis-plugin

Both should give you a good idea of which areas in the code are not tested well enough, but a mutation test score of >80% is generally really good :)

Code coverage itself is mostly a vanity metric these days: admirable, but not a clear indicator of tested/untested paths.

Originally posted by @Ocramius in #6 (comment)

Enable deprecation errors in PHPUnit

Probably worth enabling turning deprecations into errors here - PHPUnit disabled it because of Symfony's and PHP 8.1 broken design constraints, but it's good to prevent deprecations from randomly propagating to your consumers

Originally posted in #6 (comment)

Use Eums

PHP 8.1 Enum seem the right choice for many constants such as block type, code language, etc.

Unable to create RichText URL

Hello, thanks for the great SDK ๐Ÿ˜

It doesn't currently appear possible to create a RichText object with a link to a URL that's correctly formatted as a clickable link.

As an example, I currently have this code:

BulletedListItem::create()->withText([
    RichText::createText("My link: "),
    RichText::createText("https://example.com/my-link"),
]));

It's not possible to use a Text object directly as BulletedListItem only accepts RichText. https://example.com/my-link isn't clickable in Notion, I guess because the underlying text object isn't a link object (https://developers.notion.com/reference/rich-text#link-objects).

It would be great to be able to do something like the following to make the link clickable:

BulletedListItem::create()->withText([
    RichText::createText("My link: "),
    RichText::createText("https://example.com/my-link")
        ->withUrl("https://example.com/my-link"),
]));

Rename `Notion\Client` to `Notion\Notion`

I like the way you designed all this with DI in mind :)

Only complain I have is that Client itself does not have an interface, so it is hard to mock/stub.

Another detail is that Client seems to be more like an entry-point: perhaps this class could be called Notion:

$notion = Notion::create(...)->users()->...

In fact, users() gives you a client, while Notion could be expanded with further utilities later on

Originally posted by @Ocramius in #6 (comment)

How to retrieve pages from database

Does this API allow for the ability to return a set of pages from a given database? I can't seem to find any documentation or tests that handle this use-case. Perhaps I'm missing something?

Issue with files field

I have files property (Files & Media type)

Screenshot 2022-08-19 at 20 31 18

when I'm fetching my page

$page = $notion->pages()->find('f3b4ab7c34fa4b71acb0c7fa011374d9');
dd($page);

I see error

Fatal error: Uncaught Exception: Invalid property type: 'files' in /Applications/MAMP/htdocs/projects/flextype/flextype/project/plugins/notion/vendor/mariosimao/notion-sdk-php/src/Pages/Properties/Factory.php:34 Stack trace: #0 /Applications/MAMP/htdocs/projects/flextype/flextype/project/plugins/notion/vendor/mariosimao/notion-sdk-php/src/Pages/Page.php(108): Notion\Pages\Properties\Factory::fromArray(Array) #1 /Applications/MAMP/htdocs/projects/flextype/flextype/project/plugins/notion/vendor/mariosimao/notion-sdk-php/src/Pages/Client.php(57): Notion\Pages\Page::fromArray(Array) #2 /Applications/MAMP/htdocs/projects/flextype/flextype/project/plugins/notion/plugin.php(58): Notion\Pages\Client->find('f3b4ab7c34fa4b7...') #3 /Applications/MAMP/htdocs/projects/flextype/flextype/src/flextype/core/Plugins.php(423): require_once('/Applications/M...') #4 /Applications/MAMP/htdocs/projects/flextype/flextype/src/flextype/core/Plugins.php(191): Flextype\Plugins->includeEnabledPlugins() #5 /Applications/MAMP/htdocs/projects/flextype/flextype/src/flextype/core/Plugins.php(51): Flextype\Plugins->init() #6 /Applications/MAMP/htdocs/projects/flextype/flextype/src/flextype/flextype.php(350): Flextype\Plugins->__construct() #7 /Applications/MAMP/htdocs/projects/flextype/flextype/index.php(46): require_once('/Applications/M...') #8 {main} thrown in /Applications/MAMP/htdocs/projects/flextype/flextype/project/plugins/notion/vendor/mariosimao/notion-sdk-php/src/Pages/Properties/Factory.php on line 34

Database properties

Add support to database properties with one class for each property.

  • title
  • rich_text
  • number
  • select
  • multi_select
  • date
  • people
  • files
  • checkbox
  • url
  • email
  • phone_number
  • formula
  • created_time
  • created_by
  • last_edited_time
  • last_edited_by

Use `never` on `BlockInterface::changeChildren()`

With the new never return type, the method BlockInterface::changeChildren() could optionally be marked as a never returning method, due to blocks that do no accept children.

public function changeChildren(array $children): self|never

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.