notion-ruby-client 0.1.0.pre.beta1 → 1.0.0.pre.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/.devcontainer/Dockerfile +5 -0
  3. data/.devcontainer/boot.sh +1 -0
  4. data/.devcontainer/devcontainer.json +30 -0
  5. data/CHANGELOG.md +18 -0
  6. data/CONTRIBUTING.md +51 -0
  7. data/Gemfile.lock +19 -14
  8. data/README.md +113 -57
  9. data/lib/notion/api/endpoints/blocks.rb +16 -0
  10. data/lib/notion/api/endpoints/databases.rb +0 -21
  11. data/lib/notion/api/endpoints/pages.rb +20 -3
  12. data/lib/notion/api/endpoints/users.rb +8 -0
  13. data/lib/notion/version.rb +2 -2
  14. data/notion-ruby-client.gemspec +2 -2
  15. data/spec/fixtures/notion/block.yml +2 -2
  16. data/spec/fixtures/notion/block_append_children.yml +4 -4
  17. data/spec/fixtures/notion/block_children.yml +5 -5
  18. data/spec/fixtures/notion/create_database.yml +1 -1
  19. data/spec/fixtures/notion/create_page.yml +2 -2
  20. data/spec/fixtures/notion/database.yml +1 -1
  21. data/spec/fixtures/notion/database_query.yml +2 -2
  22. data/spec/fixtures/notion/delete_block.yml +145 -0
  23. data/spec/fixtures/notion/page.yml +1 -1
  24. data/spec/fixtures/notion/page_property_item.yml +143 -0
  25. data/spec/fixtures/notion/paginated_block_children.yml +8 -8
  26. data/spec/fixtures/notion/paginated_database_query.yml +1 -1
  27. data/spec/fixtures/notion/paginated_databases_list.yml +1 -1
  28. data/spec/fixtures/notion/paginated_search.yml +1 -1
  29. data/spec/fixtures/notion/paginated_users_list.yml +1 -1
  30. data/spec/fixtures/notion/search.yml +1 -1
  31. data/spec/fixtures/notion/search_with_query.yml +1 -1
  32. data/spec/fixtures/notion/update_block.yml +3 -3
  33. data/spec/fixtures/notion/update_database.yml +1 -1
  34. data/spec/fixtures/notion/update_page.yml +1 -1
  35. data/spec/fixtures/notion/users.yml +1 -1
  36. data/spec/fixtures/notion/users_list.yml +1 -1
  37. data/spec/fixtures/notion/users_me.yml +144 -0
  38. data/spec/notion/api/endpoints/blocks_spec.rb +10 -4
  39. data/spec/notion/api/endpoints/databases_spec.rb +0 -13
  40. data/spec/notion/api/endpoints/pages_spec.rb +6 -0
  41. data/spec/notion/api/endpoints/users_spec.rb +5 -0
  42. metadata +21 -13
  43. data/spec/fixtures/notion/databases_list.yml +0 -150
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a9b83ad4b81b6b52c55b8b65bf33f3075733116d91470d237d000a2428f933ea
4
- data.tar.gz: f77c9065b91514bfd3acb7ab42c8a8916c022f6725918861ab5ffce47dedd2df
3
+ metadata.gz: 79512758dde3ce8092694e5358ede8acdadb47fe58f3f21bed15c6715c4d21a5
4
+ data.tar.gz: 863b240db55feeef22c9578d9519df009fc4010aba3c2d784e757de15b80f2d3
5
5
  SHA512:
6
- metadata.gz: b080379a4840e4b925a6b7bcb5e4c5ea7a25a85856947281cc95eddcc718dd16bb14466d127fca2d2b02a028e4f5df62ea3225ac1a614057578144e43220288c
7
- data.tar.gz: aebf1260e3c10c54abebf62259beb35ab0d4ad520c8f26de98a163ed26d5e1989b09ef3d2189622a0a9b34552ac0b0d0085c567d3cd3488fc4a788fd0ba082a9
6
+ metadata.gz: f4705cd8542fc5537df2e4889523a59a7bbaca00b3c190fd6ab0a681c4f8419793f0593f831a96ea4bb4324a2065d9f05decffbba1f01ce0d3df89b8fe82265c
7
+ data.tar.gz: 6ec3e8d68bc0ff75d9c6440800fe118c79884cabf560dd28927e663a38d22c877cb2a14aafa3f2c4eb91361bf69f3f8aab04622faa1d26f281a2c66249a4deaa
@@ -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,21 @@
1
+ ### 1.0.0-beta1 (2022-03-24)
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
+
1
19
  ### 0.1.0-beta1 (2021-08-29)
2
20
 
3
21
  #### 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 (0.1.0.pre.beta1)
5
- activesupport
4
+ notion-ruby-client (1.0.0.pre.beta1)
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.4.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.9)
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.7.0)
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.1)
32
+ faraday-httpclient (~> 1.0)
33
+ faraday-multipart (~> 1.0)
33
34
  faraday-net_http (~> 1.0)
34
- faraday-net_http_persistent (~> 1.1)
35
+ faraday-net_http_persistent (~> 1.0)
35
36
  faraday-patron (~> 1.0)
36
37
  faraday-rack (~> 1.0)
37
- multipart-post (>= 1.2, < 3)
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
- faraday_middleware (1.1.0)
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 (4.1.0)
51
- i18n (1.8.10)
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.14.4)
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.2)
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
- "property": "Last ordered",
129
- "direction": "ascending"
134
+ 'property': 'Last ordered',
135
+ 'direction': 'ascending'
130
136
  }
131
137
  ]
132
138
  filter = {
133
- "or": [
139
+ 'or': [
134
140
  {
135
- "property": "In stock",
136
- "checkbox": {
137
- "equals": true
141
+ 'property': 'In stock',
142
+ 'checkbox': {
143
+ 'equals': true
138
144
  }
139
145
  },
140
146
  {
141
- "property": "Cost of next trip",
142
- "number": {
143
- "greater_than_or_equal_to": 2
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
- "type": "text",
163
- "text": {
164
- "content": "Grocery List",
165
- "link": nil
168
+ 'type': 'text',
169
+ 'text': {
170
+ 'content': 'Grocery List',
171
+ 'link': nil
166
172
  }
167
173
  }
168
174
  ]
169
175
  properties = {
170
- "Name": {
171
- "title": {}
176
+ 'Name': {
177
+ 'title': {}
172
178
  },
173
- "Description": {
174
- "rich_text": {}
179
+ 'Description': {
180
+ 'rich_text': {}
175
181
  },
176
- "In stock": {
177
- "checkbox": {}
182
+ 'In stock': {
183
+ 'checkbox': {}
178
184
  },
179
- "Food group": {
180
- "select": {
181
- "options": [
185
+ 'Food group': {
186
+ 'select': {
187
+ 'options': [
182
188
  {
183
- "name": "🥦Vegetable",
184
- "color": "green"
189
+ 'name': '🥦Vegetable',
190
+ 'color': 'green'
185
191
  },
186
192
  {
187
- "name": "🍎Fruit",
188
- "color": "red"
193
+ 'name': '🍎Fruit',
194
+ 'color': 'red'
189
195
  },
190
196
  {
191
- "name": "💪Protein",
192
- "color": "yellow"
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
- "text": {
215
- "content": "Orbit 💜 Notion"
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
- "Name": {
279
- "title": [
284
+ 'Name': {
285
+ 'title': [
280
286
  {
281
- "text": {
282
- "content": "Tuscan Kale"
287
+ 'text': {
288
+ 'content': 'Tuscan Kale'
283
289
  }
284
290
  }
285
291
  ]
286
292
  },
287
- "Description": {
288
- "rich_text": [
293
+ 'Description': {
294
+ 'rich_text': [
289
295
  {
290
- "text": {
291
- "content": "A dark green leafy vegetable"
296
+ 'text': {
297
+ 'content': 'A dark green leafy vegetable'
292
298
  }
293
299
  }
294
300
  ]
295
301
  },
296
- "Food group": {
297
- "name": "🥦 Vegetable"
302
+ 'Food group': {
303
+ 'select': {
304
+ 'name': '🥦 Vegetable'
305
+ }
298
306
  },
299
- "Price": 2.5
307
+ 'Price': {
308
+ 'number': 2.5
309
+ }
300
310
  }
301
311
  children = [
302
312
  {
303
- "object": "block",
304
- "type": "heading_2",
305
- "heading_2": {
306
- "text": [{ "type": "text", "text": { "content": "Lacinato kale" } }]
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
- "object": "block",
311
- "type": "paragraph",
312
- "paragraph": {
313
- "text": [
323
+ 'object': 'block',
324
+ 'type": 'paragraph',
325
+ 'paragraph': {
326
+ 'rich_text': [
314
327
  {
315
- "type": "text",
316
- "text": {
317
- "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.",
318
- "link": { "url": "https://en.wikipedia.org/wiki/Lacinato_kale" }
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
- "In stock": true
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
- 'text': [{
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
- "heading_2": {
411
- "text": [{ "type": 'text', "text": { "content": 'A Second-level Heading' } }]
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 arguments :page_id missing') if options[:page_id].nil?
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 arguments :parent.database_id missing') if options.dig(:parent, :database_id).nil?
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 arguments :page_id missing') if options[:page_id].nil?
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
  #
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  module Notion
3
- VERSION = '0.1.0-beta1'
4
- NOTION_REQUEST_VERSION = '2021-08-16'
3
+ VERSION = '1.0.0-beta1'
4
+ NOTION_REQUEST_VERSION = '2022-02-22'
5
5
  end
@@ -15,11 +15,11 @@ Gem::Specification.new do |s|
15
15
  s.homepage = 'http://github.com/orbit-love/notion-ruby-client'
16
16
  s.licenses = ['MIT']
17
17
  s.summary = 'Notion API client for Ruby.'
18
- s.add_dependency 'activesupport'
18
+ s.add_dependency 'activesupport', '~> 6'
19
19
  s.add_dependency 'dotenv'
20
20
  s.add_dependency 'faraday', '>= 1.0'
21
21
  s.add_dependency 'faraday_middleware'
22
- s.add_dependency 'hashie'
22
+ s.add_dependency 'hashie', '~> 5'
23
23
  s.add_development_dependency 'rake', '~> 13'
24
24
  s.add_development_dependency 'rspec'
25
25
  s.add_development_dependency 'rubocop', '~> 0.82.0'
@@ -14,7 +14,7 @@ http_interactions:
14
14
  Authorization:
15
15
  - Bearer <NOTION_API_TOKEN>
16
16
  Notion-Version:
17
- - '2021-08-16'
17
+ - '2022-02-22'
18
18
  Accept-Encoding:
19
19
  - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
20
20
  response:
@@ -139,7 +139,7 @@ http_interactions:
139
139
  - 68679732dfea3acb-CDG
140
140
  body:
141
141
  encoding: UTF-8
142
- string: '{"object":"block","id":"32af3324-ba02-4516-ae88-5728a4d569f4","created_time":"2021-05-01T17:13:00.000Z","last_edited_time":"2021-08-29T17:18:00.000Z","has_children":true,"type":"paragraph","paragraph":{"text":[{"type":"text","text":{"content":"A
142
+ string: '{"object":"block","id":"32af3324-ba02-4516-ae88-5728a4d569f4","created_time":"2021-05-01T17:13:00.000Z","last_edited_time":"2021-08-29T17:18:00.000Z","has_children":true,"type":"paragraph","paragraph":{"rich_text":[{"type":"text","text":{"content":"A
143
143
  paragraph with childrens","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"A
144
144
  paragraph with childrens","href":null}]}}'
145
145
  recorded_at: Sun, 29 Aug 2021 17:45:01 GMT