Skip to content

Commit

Permalink
Merge pull request #9 from jonathangomz/v1.1.0
Browse files Browse the repository at this point in the history
* Add more blocks support for `(PATCH): block children` endpoint
  * `BulletedListItem` block
  * `NumberedListItem` block
  * `Toggle` block
* Add `children` field for blocks:
  * `BulletedListItem`
  * `NumberedListItem`
  * `ToDo`
  * `Toggle`
  * `Paragraph`
* Add methods to manipulate `content` and `children` for blocks:
  * `addText(String text, {TextAnnotations? annotations})`
  * `addChild(Block block)`
  * `addChildren(List<Block> blocks)`
* Add `Children.withBlocks(List<Block> blocks)` constructor
* Add `final` for `type` fields to not allow overwrite:
  * Objects
  * Blocks
* Add `BaseClient` class to avoid duplicated code for clients
* Add `deprecated` annotations for future changes:
  * Remove `textSeparation` parameter/field
  * Remove `add(Text text)` function
  * Remove `texts` getter for `Paragraph`
  * Remove named parameters for `Children` class
* Update documentation
  • Loading branch information
jonathangomz authored Jul 11, 2021
2 parents f88a5bc + 983e67e commit af3d8e4
Show file tree
Hide file tree
Showing 39 changed files with 1,043 additions and 203 deletions.
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
TEST_DATABASE_ID: ${{ secrets.TEST_DATABASE_ID }}
TEST_PAGE_ID: ${{ secrets.TEST_PAGE_ID }}
TEST_BLOCK_ID: ${{ secrets.TEST_BLOCK_ID }}
TEST_BLOCK_HEADING_ID: ${{ secrets.TEST_BLOCK_HEADING_ID }}
EXEC_ENV: 'github_actions'

- name: Format coverage
Expand Down
30 changes: 29 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,32 @@
> Release date: 05/Jul/2021
* Fix warnings for documentation
* Improve documentation
* Add contribution rules
* Add contribution rules

## v1.1.0:
> Release date: 10/Jul/2021
* Add more blocks support for `(PATCH): block children` endpoint
* `BulletedListItem` block
* `NumberedListItem` block
* `Toggle` block
* Add `children` field for blocks:
* `BulletedListItem`
* `NumberedListItem`
* `ToDo`
* `Toggle`
* `Paragraph`
* Add methods to manipulate `content` and `children` for blocks:
* `addText(String text, {TextAnnotations? annotations})`
* `addChild(Block block)`
* `addChildren(List<Block> blocks)`
* Add `Children.withBlocks(List<Block> blocks)` constructor
* Add `final` for `type` fields to not allow overwrite:
* Objects
* Blocks
* Add `BaseClient` class to avoid duplicated code for clients
* Add `deprecated` annotations for future changes:
* Remove `textSeparation` parameter/field
* Remove `add(Text text)` function
* Remove `texts` getter for `Paragraph`
* Remove named parameters for `Children` class
* Update documentation
17 changes: 4 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ See the [ROADMAP](ROADMAP.md) file to see what is coming next.
- [Tests](#tests)
- [Example:](#example)
- [Next release](#next-release)
- [v1.1.0:](#v110)

# Usage
**Important**: The methods return a `NotionResponse`. You can find how to use it in its [documentation][1].
Expand Down Expand Up @@ -47,7 +46,7 @@ _To see more examples [go here](https://github.com/jonathangomz/notion_api/blob/
### Append blocks children
```dart
// Create children instance:
Children children = Children().addAll([
Children children = Children.withBlocks([
Heading(text: Text('Test')),
Paragraph(texts: [
Text('Lorem ipsum (A)'),
Expand Down Expand Up @@ -98,6 +97,7 @@ To be able to run the tests you will have to have a `.env` file on the root dire
* TEST_DATABASE_ID: The database id where you will be working on.
* TEST_PAGE_ID: Some page id inside the database specified above.
* TEST_BLOCK_ID: Some block id inside the page specified above.
* TEST_BLOCK_HEADING_ID: Some heading block id inside the page specified above.

### Example:
_The values are not valid of course._
Expand All @@ -106,19 +106,10 @@ TOKEN=secret_Oa24V8FbJ49JluJankVOQihyLiMXwqSQeeHuSFobQDW
TEST_DATABASE_ID=366da3d646bb458128071fdb2fbbf427
TEST_PAGE_ID=c3b53019-4470-443b-a141-95a3a1a44g60
TEST_BLOCK_ID=c8hac4bb32af48889228bf483d938e34
TEST_BLOCK_HEADING_ID=c8hac4bb32af48889228bf483d938e34
```

# Next release
## v1.1.0:
> Release date: 10/Jul/2021
* Add more blocks for `(PATCH): block children` endpoint
* `BulletedList` block
* `NumberedList` block
* `Toggle` block
* Add `Children.with(List<Block> blocks)` constructor
* Add singleton (_if possible_)
* Add `final` for override types to not allow change the field:
* Objects
* Blocks
I don't know yet. If you have suggestions feel free to create an Issue or to create a PR with the feature.

[1]:https://pub.dev/documentation/notion_api/1.0.0-beta1/responses_notion_response/NotionResponse-class.html
35 changes: 26 additions & 9 deletions ROADMAP.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,35 @@
# Roadmap

## More coming soon...
I don't know yet. If you have suggestions feel free to create an Issue or to create a PR with the feature.

## v1.1.0:
## v1.1.0:
> Release date: 10/Jul/2021
* Add more blocks for `(PATCH): block children` endpoint
* `BulletedList` block
* `NumberedList` block
* Add more blocks support for `(PATCH): block children` endpoint
* `BulletedListItem` block
* `NumberedListItem` block
* `Toggle` block
* Add `Children.with(List<Block> blocks)` constructor
* Add singleton (_if possible_)
* Add `final` for override types to not allow change the field:
* Objects
* Blocks
* Add `children` field for blocks:
* `BulletedListItem`
* `NumberedListItem`
* `ToDo`
* `Toggle`
* `Paragraph`
* Add methods to manipulate `content` and `children` for blocks:
* `addText(String text, {TextAnnotations? annotations})`
* `addChild(Block block)`
* `addChildren(List<Block> blocks)`
* Add `Children.withBlocks(List<Block> blocks)` constructor
* Add `final` for `type` fields to not allow overwrite:
* Objects
* Blocks
* Add `BaseClient` class to avoid duplicated code for clients
* Add `deprecated` annotations for future changes:
* Remove `textSeparation` parameter/field
* Remove `add(Text text)` function
* Remove `texts` getter for `Paragraph`
* Remove named parameters for `Children` class
* Update documentation

## v1.0.2: ✅
> Release date: 05/Jul/2021
Expand Down
181 changes: 149 additions & 32 deletions example/example.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@
- [Block children](#block-children)
- [Retrieve block children](#retrieve-block-children)
- [Append block children](#append-block-children)
- [Example](#example)
- [Heading & Paragraph](#heading--paragraph)
- [Code](#code)
- [Result](#result)
- [To do](#to-do)
- [Code](#code-1)
- [Result](#result-1)
- [Heading & Paragraph](#heading--paragraph)
- [To do](#to-do)
- [Toggle](#toggle)
- [Bulleted List Item](#bulleted-list-item)
- [Numbered List Item](#numbered-list-item)

# Initialization
## Full instance
Expand Down Expand Up @@ -99,12 +97,11 @@ _Parameters:_
- The `Paragraph` object can contain only `Text` objects.
- `Text` can receive a `TextAnnotations` class with the style of the text.

### Example
#### Heading & Paragraph
##### Code
### Heading & Paragraph
**Code**
```dart
// Create children instance:
// * Old way
// * Deprecated way
// Children oldWay = Children(
// heading: Heading('Test'),
// paragraph: Paragraph(
Expand All @@ -127,42 +124,69 @@ Children childrenA = Children().addAll([
Heading(text: Text('Test')),
Paragraph(texts: [
Text('Lorem ipsum (A)'),
Text('Lorem ipsum (B)',
annotations: TextAnnotations(
bold: true,
underline: true,
color: ColorsTypes.Orange,
))
])
Text(
'Lorem ipsum (B)',
annotations: TextAnnotations(
bold: true,
underline: true,
color: ColorsTypes.Orange,
),
),
], children: [
Heading(text: Text('Subtitle'), type: 3),
]),
]);
// * New way using single `add()`
Children childrenB =
Children().add(Heading(text: Text('Test'))).add(Paragraph(texts: [
Text('Lorem ipsum (A)'),
Text('Lorem ipsum (B)',
annotations: TextAnnotations(
bold: true,
underline: true,
color: ColorsTypes.Orange,
))
]));
annotations: TextAnnotations(
bold: true,
underline: true,
color: ColorsTypes.Orange,
),
),
], children: [
Heading(text: Text('Subtitle'), type: 3),
],
));
// * New way using `withBlocks()` constructor
Children childrenC = Children.withBlocks([
Heading(text: Text('Test')),
Paragraph(texts: [
Text('Lorem ipsum (A)'),
Text(
'Lorem ipsum (B)',
annotations: TextAnnotations(
bold: true,
underline: true,
color: ColorsTypes.Orange,
),
),
], children: [
Heading(text: Text('Subtitle'), type: 3),
]),
]);
// Send the instance to Notion
notion.blocks.append(
to: 'YOUR_BLOCK_ID',
children: childrenB, // or `childrenA`, both are the same.
children: childrenA, // or `childrenB` or `childrenC`, any of these will produce the same result.
);
```

##### Result
![heading&paragraph](https://raw.githubusercontent.com/jonathangomz/notion_api/main/example/images/heading_paragraph.png)
**Result**

![heading&paragraph](https://raw.githubusercontent.com/jonathangomz/notion_api/main/example/images/headingAndParagraph.png)

#### To do
##### Code
### To do
**Code**
```dart
// Create children instance:
// * Old way
// * Deprecated way
// Children children =
// Children(
// toDo: [
Expand All @@ -181,7 +205,7 @@ notion.blocks.append(
//
// * New way
Children children =
Children().addAll([
Children.withBlocks([
ToDo(text: Text('This is a todo item A')),
ToDo(
texts: [
Expand All @@ -192,6 +216,10 @@ Children children =
),
],
),
ToDo(text: Text('Todo item with children'), children: [
BulletedListItem(text: Text('A')),
BulletedListItem(text: Text('B')),
]),
],
);
Expand All @@ -202,7 +230,96 @@ notion.blocks.append(
);
```

##### Result
**Result**
![todo](https://raw.githubusercontent.com/jonathangomz/notion_api/main/example/images/todo.png)

### Toggle
**Code**
```dart
Children children =
Children.withBlocks([
Toggle(
text: Text('This is a toggle block'),
children: [
Paragraph(
texts: [
Text(
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas venenatis dolor sed ex egestas, et vehicula tellus faucibus. Sed pellentesque tellus eget imperdiet vulputate.')
],
),
BulletedListItem(text: Text('A')),
BulletedListItem(text: Text('B')),
BulletedListItem(text: Text('B')),
],
),
],
);
// Send the instance to Notion
notion.blocks.append(
to: 'YOUR_BLOCK_ID',
children: children,
);
```
**Result**
![toggle](https://raw.githubusercontent.com/jonathangomz/notion_api/main/example/images/toggle.png)

### Bulleted List Item
**Code**
```dart
Children children =
Children.withBlocks([
BulletedListItem(text: Text('This is a bulleted list item A')),
BulletedListItem(text: Text('This is a bulleted list item B')),
BulletedListItem(
text: Text('This is a bulleted list item with children'),
children: [
Paragraph(texts: [
Text('A'),
Text('B'),
Text('C'),
])
],
),
],
);
// Send the instance to Notion
notion.blocks.append(
to: 'YOUR_BLOCK_ID',
children: children,
);
```
**Result**
![bulletedListItem](https://raw.githubusercontent.com/jonathangomz/notion_api/main/example/images/bulletedListItem.png)

### Numbered List Item
**Code**
```dart
Children children =
Children.withBlocks([
NumberedListItem(text: Text('This is a numbered list item A')),
NumberedListItem(text: Text('This is a numbered list item B')),
NumberedListItem(
text: Text('This is a bulleted list item with children'),
children: [
Paragraph(texts: [
Text('A'),
Text('B'),
Text('C'),
])
],
),
],
);
// Send the instance to Notion
notion.blocks.append(
to: 'YOUR_BLOCK_ID',
children: children,
);
```
**Result**
![numberedListItem](https://raw.githubusercontent.com/jonathangomz/notion_api/main/example/images/numberedListItem.png)

[1]: https://developers.notion.com/reference/get-databases
Binary file added example/images/bulletedListItem.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/images/headingAndParagraph.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/images/numberedListItem.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified example/images/todo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/images/toggle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit af3d8e4

Please sign in to comment.