notion-ruby-client 0.1.0.pre.beta1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.devcontainer/Dockerfile +5 -0
- data/.devcontainer/boot.sh +1 -0
- data/.devcontainer/devcontainer.json +30 -0
- data/CHANGELOG.md +42 -0
- data/CONTRIBUTING.md +51 -0
- data/Gemfile.lock +19 -14
- data/README.md +113 -57
- data/lib/notion/api/endpoints/blocks.rb +16 -0
- data/lib/notion/api/endpoints/databases.rb +0 -21
- data/lib/notion/api/endpoints/pages.rb +20 -3
- data/lib/notion/api/endpoints/users.rb +8 -0
- data/lib/notion/version.rb +2 -2
- data/notion-ruby-client.gemspec +3 -3
- data/spec/fixtures/notion/block.yml +2 -2
- data/spec/fixtures/notion/block_append_children.yml +4 -4
- data/spec/fixtures/notion/block_children.yml +5 -5
- data/spec/fixtures/notion/create_database.yml +1 -1
- data/spec/fixtures/notion/create_page.yml +2 -2
- data/spec/fixtures/notion/database.yml +1 -1
- data/spec/fixtures/notion/database_query.yml +2 -2
- data/spec/fixtures/notion/delete_block.yml +145 -0
- data/spec/fixtures/notion/page.yml +1 -1
- data/spec/fixtures/notion/page_property_item.yml +143 -0
- data/spec/fixtures/notion/paginated_block_children.yml +8 -8
- data/spec/fixtures/notion/paginated_database_query.yml +1 -1
- data/spec/fixtures/notion/paginated_databases_list.yml +1 -1
- data/spec/fixtures/notion/paginated_search.yml +1 -1
- data/spec/fixtures/notion/paginated_users_list.yml +1 -1
- data/spec/fixtures/notion/search.yml +1 -1
- data/spec/fixtures/notion/search_with_query.yml +1 -1
- data/spec/fixtures/notion/update_block.yml +3 -3
- data/spec/fixtures/notion/update_database.yml +1 -1
- data/spec/fixtures/notion/update_page.yml +1 -1
- data/spec/fixtures/notion/users.yml +1 -1
- data/spec/fixtures/notion/users_list.yml +1 -1
- data/spec/fixtures/notion/users_me.yml +144 -0
- data/spec/notion/api/endpoints/blocks_spec.rb +10 -4
- data/spec/notion/api/endpoints/databases_spec.rb +0 -13
- data/spec/notion/api/endpoints/pages_spec.rb +6 -0
- data/spec/notion/api/endpoints/users_spec.rb +5 -0
- metadata +19 -11
- data/spec/fixtures/notion/databases_list.yml +0 -150
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: feb78b4f0ea816f89e61d9da9d1280e8d4d3565e0a71b1d611c2c58a1b5b7f67
|
4
|
+
data.tar.gz: e21ab58acc5a8414bfaccf21071a68e3ab37b11933448faed332347f597bc89b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39b6ffaf9f003c928c8eb358237419f68a0578d84f8e7ce0e3eaa548afffd5754fe721696335c6476f7a02dbf0975b1d0095496eeaa6ef01bf658234efbf9882
|
7
|
+
data.tar.gz: 9174977cdd22e7af3516a118d2c282f60bebaea8ef756d9cc0eef5cbcbfb5ef285cb6cadfe35e738c31b62778893257c0498d8150beae8d02ab495867c9c3610
|
@@ -0,0 +1,5 @@
|
|
1
|
+
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.191.1/containers/ruby/.devcontainer/base.Dockerfile
|
2
|
+
|
3
|
+
# [Choice] Ruby version: 3, 3.0, 2, 2.7, 2.6
|
4
|
+
ARG VARIANT="3.0"
|
5
|
+
FROM mcr.microsoft.com/vscode/devcontainers/ruby:0-${VARIANT}
|
@@ -0,0 +1 @@
|
|
1
|
+
bundle install
|
@@ -0,0 +1,30 @@
|
|
1
|
+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
|
2
|
+
// https://github.com/microsoft/vscode-dev-containers/tree/v0.191.1/containers/ruby
|
3
|
+
{
|
4
|
+
"name": "Ruby",
|
5
|
+
"build": {
|
6
|
+
"dockerfile": "Dockerfile",
|
7
|
+
"context": "..",
|
8
|
+
"args": {
|
9
|
+
// Update 'VARIANT' to pick a Ruby version: 3, 3.0, 2, 2.7, 2.6
|
10
|
+
"VARIANT": "2.7",
|
11
|
+
}
|
12
|
+
},
|
13
|
+
|
14
|
+
// Set *default* container specific settings.json values on container create.
|
15
|
+
"settings": {},
|
16
|
+
|
17
|
+
// Add the IDs of extensions you want installed when the container is created.
|
18
|
+
"extensions": [
|
19
|
+
"rebornix.Ruby"
|
20
|
+
],
|
21
|
+
|
22
|
+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
23
|
+
// "forwardPorts": [],
|
24
|
+
|
25
|
+
// Use 'postCreateCommand' to run commands after the container is created.
|
26
|
+
"postCreateCommand": ".devcontainer/boot.sh",
|
27
|
+
|
28
|
+
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
|
29
|
+
"remoteUser": "vscode"
|
30
|
+
}
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,45 @@
|
|
1
|
+
### 1.0.0 (2022-03-30)
|
2
|
+
|
3
|
+
#### New
|
4
|
+
|
5
|
+
- Add support for the following new endpoints:
|
6
|
+
- [Delete a block](https://developers.notion.com/reference/get-block-children)
|
7
|
+
- [Retrieve your token's bot user](https://developers.notion.com/reference/get-self)
|
8
|
+
- [Retrieve a page property item](https://developers.notion.com/reference/retrieve-a-page-property)
|
9
|
+
- Update Notion API Version to `2022-02-22` (thanks @hkob!)
|
10
|
+
- Remove the following deprecated endpoint:
|
11
|
+
- [List databases](https://developers.notion.com/reference/get-databases)
|
12
|
+
- Add Codespaces and CONTRIBUTING.md command for better DX
|
13
|
+
- Overhauled documentation
|
14
|
+
|
15
|
+
### Upgrade instructions
|
16
|
+
|
17
|
+
- Please refer to the Notion Changelog to see breaking changes for version `2022-02-22`: https://developers.notion.com/changelog/releasing-notion-version-2022-02-22
|
18
|
+
|
19
|
+
### 1.0.0-beta2 (2022-03-24)
|
20
|
+
|
21
|
+
#### Fixed
|
22
|
+
|
23
|
+
Fixed compat with Rails 7
|
24
|
+
|
25
|
+
### 1.0.0-beta1 (2022-03-24)
|
26
|
+
|
27
|
+
#### New
|
28
|
+
|
29
|
+
- Add support for the following new endpoints:
|
30
|
+
- [Delete a block](https://developers.notion.com/reference/get-block-children)
|
31
|
+
- [Retrieve your token's bot user](https://developers.notion.com/reference/get-self)
|
32
|
+
- [Retrieve a page property item](https://developers.notion.com/reference/retrieve-a-page-property)
|
33
|
+
- Update Notion API Version to `2022-02-22` (thanks @hkob!)
|
34
|
+
- Remove the following deprecated endpoint:
|
35
|
+
- [List databases](https://developers.notion.com/reference/get-databases)
|
36
|
+
- Add Codespaces and CONTRIBUTING.md command for better DX
|
37
|
+
- Overhauled documentation
|
38
|
+
|
39
|
+
#### Upgrade instructions
|
40
|
+
|
41
|
+
- Please refer to the Notion Changelog to see breaking changes for version `2022-02-22`: https://developers.notion.com/changelog/releasing-notion-version-2022-02-22
|
42
|
+
|
1
43
|
### 0.1.0-beta1 (2021-08-29)
|
2
44
|
|
3
45
|
#### New
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# CONTRIBUTING
|
2
|
+
|
3
|
+
_This project is intended to be a safe, welcoming space for collaboration. By participating in this project you agree to abide by the [Contributor Code of Conduct](CODE_OF_CONDUCT.md)._
|
4
|
+
|
5
|
+
Hi there! We're thrilled that you'd like to contribute to this project. Your help is essential for keeping it great.
|
6
|
+
|
7
|
+
## Running the project
|
8
|
+
|
9
|
+
### GitHub Codespaces
|
10
|
+
|
11
|
+
This repository includes configuration for GitHub Codespaces, making it easy to set up a cloud-based development environment. Follow [GitHub's guide](https://docs.github.com/en/codespaces/developing-in-codespaces/creating-a-codespace#creating-a-codespace) to get started.
|
12
|
+
|
13
|
+
The Codespaces environment has the dependencies all installed, and should be ready to tinker with. Once your Codespace is set up, you can check that everything works as intended by running the specs:
|
14
|
+
|
15
|
+
```
|
16
|
+
bundle exec rake
|
17
|
+
```
|
18
|
+
|
19
|
+
### Running the project locally
|
20
|
+
|
21
|
+
You can also install the project on your machine:
|
22
|
+
|
23
|
+
```
|
24
|
+
git clone https://github.com/orbit-love/notion-ruby-client.git
|
25
|
+
cd notion-ruby-client
|
26
|
+
# if you do not have bundler installed already, run
|
27
|
+
# $ gem install bundle
|
28
|
+
# to install it
|
29
|
+
bundle install
|
30
|
+
```
|
31
|
+
|
32
|
+
You can check that everything works as intended by running the specs:
|
33
|
+
|
34
|
+
```
|
35
|
+
bundle exec rake
|
36
|
+
```
|
37
|
+
|
38
|
+
## Interactive console
|
39
|
+
|
40
|
+
You can run
|
41
|
+
|
42
|
+
```
|
43
|
+
bin/console
|
44
|
+
```
|
45
|
+
|
46
|
+
to start an IRB (interactive Ruby console) session with all the gem files loaded.
|
47
|
+
Usually, you’d start such sessions by defining your `client`:
|
48
|
+
|
49
|
+
```
|
50
|
+
client = Notion::Client.new(token: <Your Notion API token>)
|
51
|
+
```
|
data/Gemfile.lock
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
notion-ruby-client (
|
5
|
-
activesupport
|
4
|
+
notion-ruby-client (1.0.0)
|
5
|
+
activesupport (>= 6)
|
6
6
|
dotenv
|
7
7
|
faraday (>= 1.0)
|
8
8
|
faraday_middleware
|
9
|
-
hashie
|
9
|
+
hashie (~> 5)
|
10
10
|
|
11
11
|
GEM
|
12
12
|
remote: http://rubygems.org/
|
13
13
|
specs:
|
14
|
-
activesupport (6.1.
|
14
|
+
activesupport (6.1.5)
|
15
15
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
16
16
|
i18n (>= 1.6, < 2)
|
17
17
|
minitest (>= 5.1)
|
@@ -20,38 +20,42 @@ GEM
|
|
20
20
|
addressable (2.8.0)
|
21
21
|
public_suffix (>= 2.0.2, < 5.0)
|
22
22
|
ast (2.4.2)
|
23
|
-
concurrent-ruby (1.1.
|
23
|
+
concurrent-ruby (1.1.10)
|
24
24
|
crack (0.4.5)
|
25
25
|
rexml
|
26
26
|
diff-lcs (1.4.4)
|
27
27
|
dotenv (2.7.6)
|
28
|
-
faraday (1.
|
28
|
+
faraday (1.10.0)
|
29
29
|
faraday-em_http (~> 1.0)
|
30
30
|
faraday-em_synchrony (~> 1.0)
|
31
31
|
faraday-excon (~> 1.1)
|
32
|
-
faraday-httpclient (~> 1.0
|
32
|
+
faraday-httpclient (~> 1.0)
|
33
|
+
faraday-multipart (~> 1.0)
|
33
34
|
faraday-net_http (~> 1.0)
|
34
|
-
faraday-net_http_persistent (~> 1.
|
35
|
+
faraday-net_http_persistent (~> 1.0)
|
35
36
|
faraday-patron (~> 1.0)
|
36
37
|
faraday-rack (~> 1.0)
|
37
|
-
|
38
|
+
faraday-retry (~> 1.0)
|
38
39
|
ruby2_keywords (>= 0.0.4)
|
39
40
|
faraday-em_http (1.0.0)
|
40
41
|
faraday-em_synchrony (1.0.0)
|
41
42
|
faraday-excon (1.1.0)
|
42
43
|
faraday-httpclient (1.0.1)
|
44
|
+
faraday-multipart (1.0.3)
|
45
|
+
multipart-post (>= 1.2, < 3)
|
43
46
|
faraday-net_http (1.0.1)
|
44
47
|
faraday-net_http_persistent (1.2.0)
|
45
48
|
faraday-patron (1.0.0)
|
46
49
|
faraday-rack (1.0.0)
|
47
|
-
|
50
|
+
faraday-retry (1.0.3)
|
51
|
+
faraday_middleware (1.2.0)
|
48
52
|
faraday (~> 1.0)
|
49
53
|
hashdiff (1.0.1)
|
50
|
-
hashie (
|
51
|
-
i18n (1.
|
54
|
+
hashie (5.0.0)
|
55
|
+
i18n (1.10.0)
|
52
56
|
concurrent-ruby (~> 1.0)
|
53
57
|
jaro_winkler (1.5.4)
|
54
|
-
minitest (5.
|
58
|
+
minitest (5.15.0)
|
55
59
|
multipart-post (2.1.1)
|
56
60
|
parallel (1.20.1)
|
57
61
|
parser (3.0.1.1)
|
@@ -96,10 +100,11 @@ GEM
|
|
96
100
|
addressable (>= 2.3.6)
|
97
101
|
crack (>= 0.3.2)
|
98
102
|
hashdiff (>= 0.4.0, < 2.0.0)
|
99
|
-
zeitwerk (2.4
|
103
|
+
zeitwerk (2.5.4)
|
100
104
|
|
101
105
|
PLATFORMS
|
102
106
|
arm64-darwin-20
|
107
|
+
ruby
|
103
108
|
x86_64-linux
|
104
109
|
|
105
110
|
DEPENDENCIES
|
data/README.md
CHANGED
@@ -18,16 +18,22 @@ A Ruby client for the Notion API.
|
|
18
18
|
- [Databases](#databases)
|
19
19
|
- [Query a database](#query-a-database)
|
20
20
|
- [Create a Database](#create-a-database)
|
21
|
+
- [Update a Database](#update-a-database)
|
21
22
|
- [Retrieve a database](#retrieve-a-database)
|
22
23
|
- [List databases](#list-databases)
|
23
24
|
- [Pages](#pages)
|
24
25
|
- [Retrieve a page](#retrieve-a-page)
|
25
26
|
- [Create a page](#create-a-page)
|
26
27
|
- [Update page](#update-page)
|
28
|
+
- [Retrieve a page property item](#retrieve-a-page-property-item)
|
27
29
|
- [Blocks](#blocks)
|
30
|
+
- [Retrieve a block](#retrieve-a-block)
|
31
|
+
- [Update a block](#update-a-block)
|
32
|
+
- [Delete a block](#delete-a-block)
|
28
33
|
- [Retrieve block children](#retrieve-block-children)
|
29
34
|
- [Append block children](#append-block-children)
|
30
35
|
- [Users](#users)
|
36
|
+
- [Retrieve your token's bot user](#retrieve-your-tokens-bot-user)
|
31
37
|
- [Retrieve a user](#retrieve-a-user)
|
32
38
|
- [List all users](#list-all-users)
|
33
39
|
- [Search](#search)
|
@@ -125,22 +131,22 @@ end
|
|
125
131
|
# Filter and sort the database
|
126
132
|
sort = [
|
127
133
|
{
|
128
|
-
|
129
|
-
|
134
|
+
'property': 'Last ordered',
|
135
|
+
'direction': 'ascending'
|
130
136
|
}
|
131
137
|
]
|
132
138
|
filter = {
|
133
|
-
|
139
|
+
'or': [
|
134
140
|
{
|
135
|
-
|
136
|
-
|
137
|
-
|
141
|
+
'property': 'In stock',
|
142
|
+
'checkbox': {
|
143
|
+
'equals': true
|
138
144
|
}
|
139
145
|
},
|
140
146
|
{
|
141
|
-
|
142
|
-
|
143
|
-
|
147
|
+
'property': 'Cost of next trip',
|
148
|
+
'number': {
|
149
|
+
'greater_than_or_equal_to': 2
|
144
150
|
}
|
145
151
|
}
|
146
152
|
]
|
@@ -159,37 +165,37 @@ Creates a database as a subpage in the specified parent page, with the specified
|
|
159
165
|
```ruby
|
160
166
|
title = [
|
161
167
|
{
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
168
|
+
'type': 'text',
|
169
|
+
'text': {
|
170
|
+
'content': 'Grocery List',
|
171
|
+
'link': nil
|
166
172
|
}
|
167
173
|
}
|
168
174
|
]
|
169
175
|
properties = {
|
170
|
-
|
171
|
-
|
176
|
+
'Name': {
|
177
|
+
'title': {}
|
172
178
|
},
|
173
|
-
|
174
|
-
|
179
|
+
'Description': {
|
180
|
+
'rich_text': {}
|
175
181
|
},
|
176
|
-
|
177
|
-
|
182
|
+
'In stock': {
|
183
|
+
'checkbox': {}
|
178
184
|
},
|
179
|
-
|
180
|
-
|
181
|
-
|
185
|
+
'Food group': {
|
186
|
+
'select': {
|
187
|
+
'options': [
|
182
188
|
{
|
183
|
-
|
184
|
-
|
189
|
+
'name': '🥦Vegetable',
|
190
|
+
'color': 'green'
|
185
191
|
},
|
186
192
|
{
|
187
|
-
|
188
|
-
|
193
|
+
'name': '🍎Fruit',
|
194
|
+
'color': 'red'
|
189
195
|
},
|
190
196
|
{
|
191
|
-
|
192
|
-
|
197
|
+
'name': '💪Protein',
|
198
|
+
'color': 'yellow'
|
193
199
|
}
|
194
200
|
]
|
195
201
|
}
|
@@ -211,8 +217,8 @@ Updates an existing database as specified by the parameters.
|
|
211
217
|
```ruby
|
212
218
|
title = [
|
213
219
|
{
|
214
|
-
|
215
|
-
|
220
|
+
'text': {
|
221
|
+
'content': 'Orbit 💜 Notion'
|
216
222
|
}
|
217
223
|
}
|
218
224
|
]
|
@@ -275,47 +281,54 @@ The new page may include page content, described as [blocks](https://developers.
|
|
275
281
|
|
276
282
|
```ruby
|
277
283
|
properties = {
|
278
|
-
|
279
|
-
|
284
|
+
'Name': {
|
285
|
+
'title': [
|
280
286
|
{
|
281
|
-
|
282
|
-
|
287
|
+
'text': {
|
288
|
+
'content': 'Tuscan Kale'
|
283
289
|
}
|
284
290
|
}
|
285
291
|
]
|
286
292
|
},
|
287
|
-
|
288
|
-
|
293
|
+
'Description': {
|
294
|
+
'rich_text': [
|
289
295
|
{
|
290
|
-
|
291
|
-
|
296
|
+
'text': {
|
297
|
+
'content': 'A dark green leafy vegetable'
|
292
298
|
}
|
293
299
|
}
|
294
300
|
]
|
295
301
|
},
|
296
|
-
|
297
|
-
|
302
|
+
'Food group': {
|
303
|
+
'select': {
|
304
|
+
'name': '🥦 Vegetable'
|
305
|
+
}
|
298
306
|
},
|
299
|
-
|
307
|
+
'Price': {
|
308
|
+
'number': 2.5
|
309
|
+
}
|
300
310
|
}
|
301
311
|
children = [
|
302
312
|
{
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
313
|
+
'object': 'block',
|
314
|
+
'type': 'heading_2',
|
315
|
+
'heading_2': {
|
316
|
+
'rich_text': [{
|
317
|
+
'type": 'text',
|
318
|
+
'text': { 'content': 'Lacinato kale' }
|
319
|
+
}]
|
307
320
|
}
|
308
321
|
},
|
309
322
|
{
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
323
|
+
'object': 'block',
|
324
|
+
'type": 'paragraph',
|
325
|
+
'paragraph': {
|
326
|
+
'rich_text': [
|
314
327
|
{
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
328
|
+
'type': 'text',
|
329
|
+
'text': {
|
330
|
+
'content': 'Lacinato kale is a variety of kale with a long tradition in Italian cuisine, especially that of Tuscany. It is also known as Tuscan kale, Italian kale, dinosaur kale, kale, flat back kale, palm tree kale, or black Tuscan palm.',
|
331
|
+
'link': { 'url': 'https://en.wikipedia.org/wiki/Lacinato_kale' }
|
319
332
|
}
|
320
333
|
}
|
321
334
|
]
|
@@ -339,13 +352,30 @@ If the parent is a database, the new [property values](https://developers.notion
|
|
339
352
|
|
340
353
|
```ruby
|
341
354
|
properties = {
|
342
|
-
|
355
|
+
'In stock': {
|
356
|
+
'checkbox': true
|
357
|
+
}
|
343
358
|
}
|
344
359
|
client.update_page(page_id: 'b55c9c91-384d-452b-81db-d1ef79372b75', properties: properties)
|
345
360
|
```
|
346
361
|
|
347
362
|
See the full endpoint documentation on [Notion Developers](https://developers.notion.com/reference/patch-page).
|
348
363
|
|
364
|
+
#### Retrieve a page property item
|
365
|
+
|
366
|
+
Retrieves a `property_item` object for a given `page_id` and `property_id`. Depending on the property type, the object returned will either be a value or a [paginated](#pagination) list of property item values. See [Property item objects](https://developers.notion.com/reference/property-item-object) for specifics.
|
367
|
+
|
368
|
+
To obtain `property_id`'s, use the [Retrieve a database endpoint](#retrieve-a-database).
|
369
|
+
|
370
|
+
```ruby
|
371
|
+
client.page_property_item(
|
372
|
+
page_id: 'b55c9c91-384d-452b-81db-d1ef79372b75',
|
373
|
+
property_id: 'aBcD123'
|
374
|
+
)
|
375
|
+
```
|
376
|
+
|
377
|
+
See the full endpoint documentation on [Notion Developers](https://developers.notion.com/reference/retrieve-a-page-property).
|
378
|
+
|
349
379
|
### Blocks
|
350
380
|
|
351
381
|
#### Retrieve a block
|
@@ -368,7 +398,8 @@ Updates the content for the specified block_id based on the block type. Supporte
|
|
368
398
|
|
369
399
|
```ruby
|
370
400
|
to_do = {
|
371
|
-
'
|
401
|
+
'rich_text': [{
|
402
|
+
'type': 'text',
|
372
403
|
'text': { 'content': 'Lacinato kale' }
|
373
404
|
}],
|
374
405
|
'checked': false
|
@@ -378,6 +409,18 @@ client.update_block(block_id: '9bc30ad4-9373-46a5-84ab-0a7845ee52e6', 'to_do' =>
|
|
378
409
|
|
379
410
|
See the full endpoint documentation on [Notion Developers](https://developers.notion.com/reference/retrieve-a-block).
|
380
411
|
|
412
|
+
#### Delete a block
|
413
|
+
|
414
|
+
Sets a [Block object](https://developers.notion.com/reference/block), including page blocks, to archived: true using the ID specified. Note: in the Notion UI application, this moves the block to the "Trash" where it can still be accessed and restored.
|
415
|
+
|
416
|
+
To restore the block with the API, use the [Update a block](#update-a-block) or [Update page](#update-page) respectively.
|
417
|
+
|
418
|
+
```ruby
|
419
|
+
client.delete_block(block_id: '9bc30ad4-9373-46a5-84ab-0a7845ee52e6')
|
420
|
+
```
|
421
|
+
|
422
|
+
See the full endpoint documentation on [Notion Developers](https://developers.notion.com/reference/delete-a-block).
|
423
|
+
|
381
424
|
#### Retrieve block children
|
382
425
|
|
383
426
|
Returns a paginated array of child [block objects](https://developers.notion.com/reference-link/block) contained in the block using the ID specified. In order to receive a complete representation of a block, you may need to recursively retrieve the block children of child blocks.
|
@@ -407,8 +450,11 @@ children = [
|
|
407
450
|
{
|
408
451
|
"object": 'block',
|
409
452
|
"type": 'heading_2',
|
410
|
-
|
411
|
-
|
453
|
+
'heading_2': {
|
454
|
+
'rich_text': [{
|
455
|
+
'type': 'text',
|
456
|
+
'text': { 'content': 'A Second-level Heading' }
|
457
|
+
}]
|
412
458
|
}
|
413
459
|
}
|
414
460
|
]
|
@@ -419,6 +465,16 @@ See the full endpoint documentation on [Notion Developers](https://developers.no
|
|
419
465
|
|
420
466
|
### Users
|
421
467
|
|
468
|
+
#### Retrieve your token's bot user
|
469
|
+
|
470
|
+
Retrieves the bot [User](https://developers.notion.com/reference/user) associated with the API token provided in the authorization header. The bot will have an `owner` field with information about the person who authorized the integration.
|
471
|
+
|
472
|
+
```ruby
|
473
|
+
client.me
|
474
|
+
```
|
475
|
+
|
476
|
+
See the full endpoint documentation on [Notion Developers](https://developers.notion.com/reference/get-self).
|
477
|
+
|
422
478
|
#### Retrieve a user
|
423
479
|
|
424
480
|
Retrieves a [User](https://developers.notion.com/reference/user) using the ID specified.
|
@@ -32,6 +32,22 @@ module Notion
|
|
32
32
|
patch("blocks/#{options[:block_id]}", options.except(:block_id))
|
33
33
|
end
|
34
34
|
|
35
|
+
#
|
36
|
+
# Sets a Block object, including page blocks, to archived: true
|
37
|
+
# using the ID specified. Note: in the Notion UI application, this
|
38
|
+
# moves the block to the "Trash" where it can still be accessed and
|
39
|
+
# restored.
|
40
|
+
#
|
41
|
+
# To restore the block with the API, use the Update a block or
|
42
|
+
# Update page respectively.
|
43
|
+
#
|
44
|
+
# @option options [id] :block_id
|
45
|
+
# Block to get children info on.
|
46
|
+
def delete_block(options = {})
|
47
|
+
throw ArgumentError.new('Required arguments :block_id missing') if options[:block_id].nil?
|
48
|
+
delete("blocks/#{options[:block_id]}")
|
49
|
+
end
|
50
|
+
|
35
51
|
#
|
36
52
|
# Returns a paginated array of Block objects contained in the
|
37
53
|
# block of the requested path using the ID specified.
|
@@ -101,27 +101,6 @@ module Notion
|
|
101
101
|
throw ArgumentError.new('Required arguments :database_id missing') if options[:database_id].nil?
|
102
102
|
get("databases/#{options[:database_id]}")
|
103
103
|
end
|
104
|
-
|
105
|
-
#
|
106
|
-
# Returns a paginated list of Databases objects for the workspace.
|
107
|
-
#
|
108
|
-
# @option options [UUID] :start_cursor
|
109
|
-
# Paginate through collections of data by setting the cursor parameter
|
110
|
-
# to a start_cursor attribute returned by a previous request's next_cursor.
|
111
|
-
# Default value fetches the first "page" of the collection.
|
112
|
-
# See pagination for more detail.
|
113
|
-
#
|
114
|
-
# @option options [integer] :page_size
|
115
|
-
# The number of items from the full list desired in the response. Maximum: 100
|
116
|
-
def databases_list(options = {})
|
117
|
-
if block_given?
|
118
|
-
Pagination::Cursor.new(self, :databases_list, options).each do |page|
|
119
|
-
yield page
|
120
|
-
end
|
121
|
-
else
|
122
|
-
get('databases', options)
|
123
|
-
end
|
124
|
-
end
|
125
104
|
end
|
126
105
|
end
|
127
106
|
end
|
@@ -15,7 +15,7 @@ module Notion
|
|
15
15
|
# Set to true to retrieve an archived page; must be false or omitted to
|
16
16
|
# retrieve a page that has not been archived. Defaults to false.
|
17
17
|
def page(options = {})
|
18
|
-
throw ArgumentError.new('Required
|
18
|
+
throw ArgumentError.new('Required argument :page_id missing') if options[:page_id].nil?
|
19
19
|
get("pages/#{options[:page_id]}")
|
20
20
|
end
|
21
21
|
|
@@ -38,7 +38,7 @@ module Notion
|
|
38
38
|
# @option options [Object] :children
|
39
39
|
# An optional array of Block objects representing the Page’s content
|
40
40
|
def create_page(options = {})
|
41
|
-
throw ArgumentError.new('Required
|
41
|
+
throw ArgumentError.new('Required argument :parent.database_id missing') if options.dig(:parent, :database_id).nil?
|
42
42
|
post("pages", options)
|
43
43
|
end
|
44
44
|
|
@@ -60,9 +60,26 @@ module Notion
|
|
60
60
|
# appears in Notion, or property ID. value object Object containing a value
|
61
61
|
# specific to the property type, e.g. {"checkbox": true}.
|
62
62
|
def update_page(options = {})
|
63
|
-
throw ArgumentError.new('Required
|
63
|
+
throw ArgumentError.new('Required argument :page_id missing') if options[:page_id].nil?
|
64
64
|
patch("pages/#{options[:page_id]}", options.except(:page_id))
|
65
65
|
end
|
66
|
+
|
67
|
+
#
|
68
|
+
# Retrieves a `property_item` object for a given `page_id` and `property_id`.
|
69
|
+
# Depending on the property type, the object returned will either be a value
|
70
|
+
# or a paginated list of property item values.
|
71
|
+
#
|
72
|
+
# @option options [id] :page_id
|
73
|
+
# Page to get info on.
|
74
|
+
#
|
75
|
+
# @option options [id] :property_id
|
76
|
+
# Property to get info on.
|
77
|
+
#
|
78
|
+
def page_property_item(options = {})
|
79
|
+
throw ArgumentError.new('Required argument :page_id missing') if options[:page_id].nil?
|
80
|
+
throw ArgumentError.new('Required argument :property_id missing') if options[:property_id].nil?
|
81
|
+
get("pages/#{options[:page_id]}/properties/#{options[:property_id]}")
|
82
|
+
end
|
66
83
|
end
|
67
84
|
end
|
68
85
|
end
|
@@ -4,6 +4,14 @@ module Notion
|
|
4
4
|
module Api
|
5
5
|
module Endpoints
|
6
6
|
module Users
|
7
|
+
#
|
8
|
+
# Retrieves the bot User associated with the API token provided in
|
9
|
+
# the authorization header. The bot will have an `owner` field with
|
10
|
+
# information about the person who authorized the integration.
|
11
|
+
def me
|
12
|
+
get("users/me")
|
13
|
+
end
|
14
|
+
|
7
15
|
#
|
8
16
|
# Retrieves a User object using the ID specified in the request.
|
9
17
|
#
|
data/lib/notion/version.rb
CHANGED