notion-ruby-client 0.0.2 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +14 -0
  3. data/.rspec +2 -0
  4. data/.rspec_status +18 -0
  5. data/.rubocop.yml +46 -0
  6. data/.rubocop_todo.yml +86 -0
  7. data/CHANGELOG.md +30 -0
  8. data/CODE_OF_CONDUCT.md +128 -0
  9. data/Gemfile.lock +95 -0
  10. data/README.md +192 -3
  11. data/Rakefile +18 -0
  12. data/lib/notion-ruby-client.rb +6 -7
  13. data/lib/notion/api/endpoints.rb +6 -0
  14. data/lib/notion/api/endpoints/blocks.rb +53 -0
  15. data/lib/notion/api/endpoints/databases.rb +78 -0
  16. data/lib/notion/api/endpoints/pages.rb +69 -0
  17. data/lib/notion/api/endpoints/users.rb +7 -3
  18. data/lib/notion/api/errors.rb +7 -1
  19. data/lib/notion/api/errors/notion_error.rb +2 -2
  20. data/lib/notion/config.rb +3 -1
  21. data/lib/notion/faraday/request.rb +8 -2
  22. data/lib/notion/faraday/response/raise_error.rb +3 -4
  23. data/lib/notion/pagination/cursor.rb +2 -2
  24. data/lib/notion/version.rb +3 -2
  25. data/notion-ruby-client-0.0.4.gem +0 -0
  26. data/spec/fixtures/notion/block_append_children.yml +135 -0
  27. data/spec/fixtures/notion/block_children.yml +137 -0
  28. data/spec/fixtures/notion/create_page.yml +137 -0
  29. data/spec/fixtures/notion/database.yml +133 -0
  30. data/spec/fixtures/notion/database_query.yml +135 -0
  31. data/spec/fixtures/notion/databases_list.yml +133 -0
  32. data/spec/fixtures/notion/page.yml +133 -0
  33. data/spec/fixtures/notion/paginated_block_children.yml +521 -0
  34. data/spec/fixtures/notion/paginated_database_query.yml +135 -0
  35. data/spec/fixtures/notion/paginated_databases_list.yml +133 -0
  36. data/spec/fixtures/notion/paginated_users_list.yml +133 -0
  37. data/spec/fixtures/notion/update_page.yml +136 -0
  38. data/spec/fixtures/notion/users.yml +132 -0
  39. data/spec/fixtures/notion/users_list.yml +133 -0
  40. data/spec/notion/api/endpoints/blocks_spec.rb +40 -0
  41. data/spec/notion/api/endpoints/databases_spec.rb +40 -0
  42. data/spec/notion/api/endpoints/pages_spec.rb +64 -0
  43. data/spec/notion/api/endpoints/users_spec.rb +26 -0
  44. data/spec/notion/config_spec.rb +16 -0
  45. data/spec/notion/version_spec.rb +8 -0
  46. data/spec/spec_helper.rb +22 -0
  47. data/spec/support/token.rb +10 -0
  48. data/spec/support/vcr.rb +16 -0
  49. metadata +67 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f21b181770c49f8d02f34bdcf949fbc19ccbbd7e7cb62bee02163abf64fd80f5
4
- data.tar.gz: 599580c1772892e31227fe369fdb478408442c12320f8fb6109da32f58f516ca
3
+ metadata.gz: 54a7b7076dce99aa2eec8b0ba041d2f1bfbdd1558a2ee94f76fe27112a726405
4
+ data.tar.gz: 11b710cf49ae369d53b023278ddfe6fe54f9c5eb4cc0d74922966f0d97f45b7f
5
5
  SHA512:
6
- metadata.gz: 59d8fe6a3a90b9286cb5a09561263d4bb48330727d0c3daa0752aa11d5caeadeb02a66287e64dd9efa25dc72c31e0dc28aa91d233974ce93b3dda68734fabd75
7
- data.tar.gz: 8d9c80c3d970fcb0e3715d325c091d3f95b85172850cc671c4a4f651e507e4b3adb8886aabd2a1288035be82f415013a26a5a3c583fc3db1e68d6926a2ebb3b9
6
+ metadata.gz: 415e4801fd99af01efe431edd03cef55b27a1436a089a69a3bf3cbb986109a810223736e8cb415dd8e60a4066e476af3e7d5736a5ffeb96002fd599e3bd24e0f
7
+ data.tar.gz: a26e034921948f495a28362f4ce392601f02e795ee1eac93fa41100df0781522b6a7488e2957b7b80e1fcaaa629433ba9f95aee7121d8a15abb20596a17e16ff
@@ -0,0 +1,14 @@
1
+ on: [push, pull_request]
2
+ jobs:
3
+ test:
4
+ strategy:
5
+ matrix:
6
+ ruby: [2.5, 2.6, 2.7]
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@v2
10
+ - uses: ruby/setup-ruby@v1
11
+ with:
12
+ bundler-cache: true
13
+ ruby-version: ${{ matrix.ruby }}
14
+ - run: bundle exec rake
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.rspec_status ADDED
@@ -0,0 +1,18 @@
1
+ example_id | status | run_time |
2
+ ---------------------------------------------------- | ------ | --------------- |
3
+ ./spec/notion/api/endpoints/blocks_spec.rb[1:1:1] | passed | 0.01423 seconds |
4
+ ./spec/notion/api/endpoints/blocks_spec.rb[1:1:2] | passed | 0.02323 seconds |
5
+ ./spec/notion/api/endpoints/blocks_spec.rb[1:1:3] | passed | 0.00704 seconds |
6
+ ./spec/notion/api/endpoints/databases_spec.rb[1:1:1] | passed | 0.00598 seconds |
7
+ ./spec/notion/api/endpoints/databases_spec.rb[1:1:2] | passed | 0.00628 seconds |
8
+ ./spec/notion/api/endpoints/databases_spec.rb[1:1:3] | passed | 0.00548 seconds |
9
+ ./spec/notion/api/endpoints/databases_spec.rb[1:1:4] | passed | 0.00596 seconds |
10
+ ./spec/notion/api/endpoints/databases_spec.rb[1:1:5] | passed | 0.00606 seconds |
11
+ ./spec/notion/api/endpoints/pages_spec.rb[1:1:1] | passed | 0.00581 seconds |
12
+ ./spec/notion/api/endpoints/pages_spec.rb[1:1:2] | passed | 0.00598 seconds |
13
+ ./spec/notion/api/endpoints/pages_spec.rb[1:1:3] | passed | 0.00717 seconds |
14
+ ./spec/notion/api/endpoints/users_spec.rb[1:1:1] | passed | 0.00637 seconds |
15
+ ./spec/notion/api/endpoints/users_spec.rb[1:1:2] | passed | 0.00671 seconds |
16
+ ./spec/notion/api/endpoints/users_spec.rb[1:1:3] | passed | 0.00567 seconds |
17
+ ./spec/notion/config_spec.rb[1:1:1] | passed | 0.00005 seconds |
18
+ ./spec/notion/version_spec.rb[1:1] | passed | 0.00005 seconds |
data/.rubocop.yml ADDED
@@ -0,0 +1,46 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ require:
4
+ - rubocop-performance
5
+ - rubocop-rspec
6
+
7
+ AllCops:
8
+ DisplayCopNames: true
9
+ Exclude:
10
+ - bin/**/*
11
+ - vendor/**/*
12
+ - lib/notion/web/api/notion-api-ref/**/*
13
+ - lib/notion/web/api/endpoints/* # Auto-generated
14
+ - lib/notion/web/api/errors.rb # Auto-generated
15
+ - spec/notion/web/api/endpoints/* # Auto-generated
16
+
17
+ Layout/EmptyLineAfterMagicComment:
18
+ Enabled: false
19
+
20
+ Metrics/BlockLength:
21
+ Enabled: false
22
+
23
+ Metrics/ClassLength:
24
+ Max: 250
25
+
26
+ Layout/LineLength:
27
+ Max: 128
28
+
29
+ RSpec/ContextWording:
30
+ Enabled: false
31
+
32
+ RSpec/ExampleLength:
33
+ Enabled: false
34
+
35
+ RSpec/MultipleExpectations:
36
+ Enabled: false
37
+
38
+ Style/Documentation:
39
+ Enabled: false
40
+
41
+ Style/ModuleFunction:
42
+ Enabled: false
43
+
44
+ Naming/FileName:
45
+ Exclude:
46
+ - lib/notion-ruby-client.rb # Required to match gemspec name
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,86 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2021-04-25 19:55:01 +0200 using RuboCop version 0.82.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 3
10
+ # Cop supports --auto-correct.
11
+ Layout/EmptyLines:
12
+ Exclude:
13
+ - 'scratchpad.rb'
14
+ - 'spec/spec_helper.rb'
15
+
16
+ # Offense count: 5
17
+ # Configuration parameters: EnforcedStyle.
18
+ # SupportedStyles: native, lf, crlf
19
+ Layout/EndOfLine:
20
+ Exclude:
21
+ - 'Rakefile'
22
+ - 'spec/notion/config_spec.rb'
23
+ - 'spec/notion/version_spec.rb'
24
+ - 'spec/spec_helper.rb'
25
+ - 'spec/support/token.rb'
26
+
27
+ # Offense count: 26
28
+ # Cop supports --auto-correct.
29
+ # Configuration parameters: EnforcedStyle.
30
+ # SupportedStyles: final_newline, final_blank_line
31
+ Layout/TrailingEmptyLines:
32
+ Enabled: false
33
+
34
+ # Offense count: 1
35
+ # Cop supports --auto-correct.
36
+ Lint/NonDeterministicRequireOrder:
37
+ Exclude:
38
+ - 'spec/spec_helper.rb'
39
+
40
+ # Offense count: 1
41
+ Lint/UselessAssignment:
42
+ Exclude:
43
+ - 'scratchpad.rb'
44
+
45
+ # Offense count: 2
46
+ # Configuration parameters: IgnoredMethods.
47
+ Metrics/AbcSize:
48
+ Max: 30
49
+
50
+ # Offense count: 2
51
+ # Configuration parameters: IgnoredMethods.
52
+ Metrics/CyclomaticComplexity:
53
+ Max: 9
54
+
55
+ # Offense count: 4
56
+ # Configuration parameters: CountComments, ExcludedMethods.
57
+ Metrics/MethodLength:
58
+ Max: 23
59
+
60
+ # Offense count: 2
61
+ # Configuration parameters: IgnoredMethods.
62
+ Metrics/PerceivedComplexity:
63
+ Max: 9
64
+
65
+ # Offense count: 2
66
+ # Configuration parameters: AllowedChars.
67
+ Style/AsciiComments:
68
+ Exclude:
69
+ - 'lib/notion/api/endpoints/pages.rb'
70
+
71
+ # Offense count: 1
72
+ # Cop supports --auto-correct.
73
+ # Configuration parameters: EnforcedStyle.
74
+ # SupportedStyles: always, always_true, never
75
+ Style/FrozenStringLiteralComment:
76
+ Exclude:
77
+ - 'scratchpad.rb'
78
+
79
+ # Offense count: 2
80
+ # Cop supports --auto-correct.
81
+ # Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
82
+ # SupportedStyles: single_quotes, double_quotes
83
+ Style/StringLiterals:
84
+ Exclude:
85
+ - 'lib/notion/api/endpoints/pages.rb'
86
+ - 'lib/notion/api/endpoints/users.rb'
data/CHANGELOG.md ADDED
@@ -0,0 +1,30 @@
1
+ ### 0.0.7 (2021-06-17)
2
+
3
+ - Fixes the query parameter for fetching a page resource
4
+
5
+ ### 0.0.6 (2021-06-09)
6
+
7
+ - Added `Notion-Version` required header to all requests
8
+
9
+ ### 0.0.5 (2020-04-25)
10
+
11
+ - Added support for Blocks endpoints
12
+
13
+ ### 0.0.4 (2020-04-25)
14
+
15
+ - Added specs and a CI process with GitHub Actions
16
+ - Added support for GET /databases, POST /databases/<:id>/query endpoints
17
+ - Added support for `content` when creating a page
18
+
19
+ ### 0.0.3 (2020-01-30)
20
+
21
+ - The gem now covers all available endpoints to date
22
+ - Better error handling and logging
23
+
24
+ ### 0.0.2 (2020-01-29)
25
+
26
+ - Fixed blocking bug present in 0.0.1
27
+
28
+ ### 0.0.1 (2020-01-29)
29
+
30
+ - Initial alpha public release. Suffers from a bug that prevents installation.
@@ -0,0 +1,128 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, religion, or sexual identity
10
+ and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ * Demonstrating empathy and kindness toward other people
21
+ * Being respectful of differing opinions, viewpoints, and experiences
22
+ * Giving and gracefully accepting constructive feedback
23
+ * Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ * Focusing on what is best not just for us as individuals, but for the
26
+ overall community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ * The use of sexualized language or imagery, and sexual attention or
31
+ advances of any kind
32
+ * Trolling, insulting or derogatory comments, and personal or political attacks
33
+ * Public or private harassment
34
+ * Publishing others' private information, such as a physical or email
35
+ address, without their explicit permission
36
+ * Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official e-mail address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement at
63
+ nicolas@orbit.love.
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series
86
+ of actions.
87
+
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or
93
+ permanent ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within
113
+ the community.
114
+
115
+ ## Attribution
116
+
117
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
+ version 2.0, available at
119
+ https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
120
+
121
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct
122
+ enforcement ladder](https://github.com/mozilla/diversity).
123
+
124
+ [homepage]: https://www.contributor-covenant.org
125
+
126
+ For answers to common questions about this code of conduct, see the FAQ at
127
+ https://www.contributor-covenant.org/faq. Translations are available at
128
+ https://www.contributor-covenant.org/translations.
data/Gemfile.lock ADDED
@@ -0,0 +1,95 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ notion-ruby-client (0.0.6)
5
+ faraday (>= 1.0)
6
+ faraday_middleware
7
+ hashie
8
+
9
+ GEM
10
+ remote: http://rubygems.org/
11
+ specs:
12
+ addressable (2.7.0)
13
+ public_suffix (>= 2.0.2, < 5.0)
14
+ ast (2.4.2)
15
+ crack (0.4.5)
16
+ rexml
17
+ diff-lcs (1.4.4)
18
+ faraday (1.4.2)
19
+ faraday-em_http (~> 1.0)
20
+ faraday-em_synchrony (~> 1.0)
21
+ faraday-excon (~> 1.1)
22
+ faraday-net_http (~> 1.0)
23
+ faraday-net_http_persistent (~> 1.1)
24
+ multipart-post (>= 1.2, < 3)
25
+ ruby2_keywords (>= 0.0.4)
26
+ faraday-em_http (1.0.0)
27
+ faraday-em_synchrony (1.0.0)
28
+ faraday-excon (1.1.0)
29
+ faraday-net_http (1.0.1)
30
+ faraday-net_http_persistent (1.1.0)
31
+ faraday_middleware (1.0.0)
32
+ faraday (~> 1.0)
33
+ hashdiff (1.0.1)
34
+ hashie (4.1.0)
35
+ jaro_winkler (1.5.4)
36
+ multipart-post (2.1.1)
37
+ parallel (1.20.1)
38
+ parser (3.0.1.1)
39
+ ast (~> 2.4.1)
40
+ public_suffix (4.0.6)
41
+ rainbow (3.0.0)
42
+ rake (10.5.0)
43
+ rexml (3.2.5)
44
+ rspec (3.10.0)
45
+ rspec-core (~> 3.10.0)
46
+ rspec-expectations (~> 3.10.0)
47
+ rspec-mocks (~> 3.10.0)
48
+ rspec-core (3.10.1)
49
+ rspec-support (~> 3.10.0)
50
+ rspec-expectations (3.10.1)
51
+ diff-lcs (>= 1.2.0, < 2.0)
52
+ rspec-support (~> 3.10.0)
53
+ rspec-mocks (3.10.2)
54
+ diff-lcs (>= 1.2.0, < 2.0)
55
+ rspec-support (~> 3.10.0)
56
+ rspec-support (3.10.2)
57
+ rubocop (0.82.0)
58
+ jaro_winkler (~> 1.5.1)
59
+ parallel (~> 1.10)
60
+ parser (>= 2.7.0.1)
61
+ rainbow (>= 2.2.2, < 4.0)
62
+ rexml
63
+ ruby-progressbar (~> 1.7)
64
+ unicode-display_width (>= 1.4.0, < 2.0)
65
+ rubocop-performance (1.5.2)
66
+ rubocop (>= 0.71.0)
67
+ rubocop-rspec (1.39.0)
68
+ rubocop (>= 0.68.1)
69
+ ruby-progressbar (1.11.0)
70
+ ruby2_keywords (0.0.4)
71
+ timecop (0.9.4)
72
+ unicode-display_width (1.7.0)
73
+ vcr (6.0.0)
74
+ webmock (3.13.0)
75
+ addressable (>= 2.3.6)
76
+ crack (>= 0.3.2)
77
+ hashdiff (>= 0.4.0, < 2.0.0)
78
+
79
+ PLATFORMS
80
+ arm64-darwin-20
81
+ x86_64-linux
82
+
83
+ DEPENDENCIES
84
+ notion-ruby-client!
85
+ rake (~> 10)
86
+ rspec
87
+ rubocop (~> 0.82.0)
88
+ rubocop-performance (~> 1.5.2)
89
+ rubocop-rspec (~> 1.39.0)
90
+ timecop
91
+ vcr
92
+ webmock
93
+
94
+ BUNDLED WITH
95
+ 2.2.16
data/README.md CHANGED
@@ -24,7 +24,7 @@ Run `bundle install`.
24
24
 
25
25
  ### Create a New Bot Integration
26
26
 
27
- To integrate your bot with Notion, you must first create a new Notion Bot. (**TODO**: link to the docs)
27
+ To integrate your bot with Notion, you must first [create a new Notion Bot](https://www.notion.so/Getting-started-da32a6fc1bcc4403a6126ee735710d89).
28
28
 
29
29
  1. Log into the workspace that you want your integration to be associated with.
30
30
  2. Confirm that you are an Admin in the workspace (see Settings & Members > Members).
@@ -34,12 +34,201 @@ To integrate your bot with Notion, you must first create a new Notion Bot. (**TO
34
34
 
35
35
  ### Declare the API token
36
36
 
37
- ```
37
+ ```ruby
38
38
  Notion.configure do |config|
39
39
  config.token = ENV['NOTION_API_TOKEN']
40
40
  end
41
41
  ```
42
42
 
43
+ For Rails projects, the snippet above would go to `config/application.rb`.
44
+
43
45
  ### API Client
44
46
 
45
- TODO: document endpoints
47
+ #### Instanciating a new Notion API client
48
+
49
+ ```ruby
50
+ client = Notion::Client.new
51
+ ```
52
+
53
+ You can specify the token or logger on a per-client basis:
54
+
55
+ ```ruby
56
+ client = Notion::Client.new(token: '<secret Notion API token>')
57
+ ```
58
+
59
+ #### Users
60
+
61
+ Get a paginated list of [User objects](https://www.notion.so/User-object-4f8d1a2fc1e54680b5f810ed0c6903a6) for the workspace:
62
+
63
+ ```ruby
64
+ client.users_list # retrieves the first page
65
+
66
+ client.users_list(start_cursor: 'fe2cc560-036c-44cd-90e8-294d5a74cebc')
67
+
68
+ client.users_list do |page|
69
+ # paginate through all users
70
+ end
71
+ ```
72
+
73
+ Get a single User:
74
+
75
+ ```ruby
76
+ client.user(id: 'd40e767c-d7af-4b18-a86d-55c61f1e39a4')
77
+ ```
78
+
79
+ #### Databases
80
+
81
+ Gets a paginated array of Page objects contained in the requested database, filtered and ordered according to the filter and sort references provided in the request.
82
+
83
+ ```ruby
84
+ client.database_query(id: 'e383bcee-e0d8-4564-9c63-900d307abdb0') # retrieves the first page
85
+
86
+ client.database_query(id: 'e383bcee-e0d8-4564-9c63-900d307abdb0', start_cursor: 'fe2cc560-036c-44cd-90e8-294d5a74cebc')
87
+
88
+ client.database_query((id: 'e383bcee-e0d8-4564-9c63-900d307abdb0') do |page|
89
+ # paginate through all pages
90
+ end
91
+
92
+ # Filter and sort the database
93
+ sort = [
94
+ {
95
+ "property": "Last ordered",
96
+ "direction": "ascending"
97
+ }
98
+ ]
99
+ filter = {
100
+ "or": [
101
+ {
102
+ "property": "In stock",
103
+ "checkbox": {
104
+ "equals": true
105
+ }
106
+ },
107
+ {
108
+ "property": "Cost of next trip",
109
+ "number": {
110
+ "greater_than_or_equal_to": 2
111
+ }
112
+ }
113
+ ]
114
+ }
115
+ client.database_query(id: 'e383bcee-e0d8-4564-9c63-900d307abdb0', sort: sort, filter: filter)
116
+ ```
117
+
118
+ Get a single Database:
119
+
120
+ ```ruby
121
+ client.database(id: 'e383bcee-e0d8-4564-9c63-900d307abdb0')
122
+ ```
123
+
124
+ Lists databases:
125
+
126
+ ```ruby
127
+ client.databases_list # retrieves the first page
128
+
129
+ client.databases_list(start_cursor: 'fe2cc560-036c-44cd-90e8-294d5a74cebc')
130
+
131
+ client.databases_list do |page|
132
+ # paginate through all databases
133
+ end
134
+ ```
135
+
136
+ #### Pages
137
+
138
+ Create a page:
139
+
140
+ ```ruby
141
+ properties = {
142
+ "Name": [
143
+ {
144
+ "text": {
145
+ "content": "Tuscan Kale"
146
+ }
147
+ }
148
+ ],
149
+ "Description": [
150
+ {
151
+ "text": {
152
+ "content": "A dark green leafy vegetable"
153
+ }
154
+ }
155
+ ],
156
+ "Food group": {
157
+ "name": "🥦 Vegetable"
158
+ },
159
+ "Price": 2.5
160
+ }
161
+ children = [
162
+ {
163
+ "object": "block",
164
+ "type": "heading_2",
165
+ "heading_2": {
166
+ "text": [{ "type": "text", "text": { "content": "Lacinato kale" } }]
167
+ }
168
+ },
169
+ {
170
+ "object": "block",
171
+ "type": "paragraph",
172
+ "paragraph": {
173
+ "text": [
174
+ {
175
+ "type": "text",
176
+ "text": {
177
+ "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.",
178
+ "link": { "url": "https://en.wikipedia.org/wiki/Lacinato_kale" }
179
+ }
180
+ }
181
+ ]
182
+ }
183
+ }
184
+ ]
185
+ client.create_page(
186
+ parent: { database_id: 'e383bcee-e0d8-4564-9c63-900d307abdb0'},
187
+ properties: properties,
188
+ children: children
189
+ )
190
+ ```
191
+
192
+ Retrieve a page:
193
+
194
+ ```ruby
195
+ client.page(id: 'b55c9c91-384d-452b-81db-d1ef79372b75')
196
+ ```
197
+
198
+ Update page properties:
199
+
200
+ ```ruby
201
+ properties = {
202
+ "In stock": true
203
+ }
204
+ client.update_page(id: 'b55c9c91-384d-452b-81db-d1ef79372b75', properties: properties)
205
+ ```
206
+
207
+ #### Blocks
208
+
209
+ Retrieve children Block objects at the requested path:
210
+
211
+ ```ruby
212
+ client.block_children(id: 'b55c9c91-384d-452b-81db-d1ef79372b75')
213
+
214
+ client.block_children(start_cursor: 'fe2cc560-036c-44cd-90e8-294d5a74cebc')
215
+
216
+ client.block_children_list do |page|
217
+ # paginate through all children
218
+ end
219
+ ```
220
+
221
+ Creates and appends new children blocks to the parent block in the requested path:
222
+
223
+ ```ruby
224
+ children = [
225
+ {
226
+ "object": 'block',
227
+ "type": 'heading_2',
228
+ "heading_2": {
229
+ "text": [{ "type": 'text', "text": { "content": 'A Second-level Heading' } }]
230
+ }
231
+ }
232
+ ]
233
+ client.block_append_children(id: 'b55c9c91-384d-452b-81db-d1ef79372b75', children: children)
234
+ ```