notion-sdk-ruby 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,263 +1,339 @@
1
- # Notion Ruby SDK
2
-
3
- [![ci](https://github.com/mgmarlow/notion-sdk-ruby/actions/workflows/ci.yml/badge.svg)](https://github.com/mgmarlow/notion-sdk-ruby/actions/workflows/ci.yml)
4
- [![Gem Version](https://badge.fury.io/rb/notion-sdk-ruby.svg)](https://badge.fury.io/rb/notion-sdk-ruby)
5
-
6
- Unofficial Ruby client for the [Notion APIs](https://developers.notion.com/).
7
-
8
- - [Notion Ruby SDK](#notion-ruby-sdk)
9
- - [Installation](#installation)
10
- - [Usage](#usage)
11
- - [API reference](#api-reference)
12
- - [Databases](#databases)
13
- - [databases#retrieve](#databasesretrieve)
14
- - [databases#list](#databaseslist)
15
- - [databases#query](#databasesquery)
16
- - [Pages](#pages)
17
- - [pages#retrieve](#pagesretrieve)
18
- - [pages#create](#pagescreate)
19
- - [pages#update](#pagesupdate)
20
- - [Blocks](#blocks)
21
- - [blocks#children#list](#blockschildrenlist)
22
- - [blocks#children#append](#blockschildrenappend)
23
- - [Users](#users)
24
- - [users#retrieve](#usersretrieve)
25
- - [users#list](#userslist)
26
- - [Search](#search)
27
- - [#search](#search-1)
28
- - [Development](#development)
29
- - [Contributing](#contributing)
30
- - [License](#license)
31
-
32
- ## Installation
33
-
34
- Add this line to your application's Gemfile:
35
-
36
- ```ruby
37
- gem 'notion-sdk-ruby'
38
- ```
39
-
40
- And then execute:
41
-
42
- $ bundle install
43
-
44
- ## Usage
45
-
46
- Initialize `Notion::Client` with your app's [integration secret](https://developers.notion.com/docs/getting-started#create-a-new-integration).
47
-
48
- ```rb
49
- require "notion-sdk-ruby"
50
- client = Notion::Client.new(token: ENV["NOTION_API_SECRET"])
51
- ```
52
-
53
- ## API reference
54
-
55
- ### Databases
56
-
57
- #### databases#retrieve
58
-
59
- [API reference](https://developers.notion.com/reference/get-database)
60
-
61
- ```rb
62
- client.databases.retrieve("668d797c-76fa-4934-9b05-ad288df2d136")
63
- ```
64
-
65
- #### databases#list
66
-
67
- [API reference](https://developers.notion.com/reference/get-databases)
68
-
69
- ```rb
70
- client.databases.list
71
- ```
72
-
73
- #### databases#query
74
-
75
- [API reference](https://developers.notion.com/reference/post-database-query)
76
-
77
- ```rb
78
- client.databases.query("668d797c-76fa-4934-9b05-ad288df2d136", {
79
- "filter": {
80
- "or": [
81
- {
82
- "property": "In stock",
83
- "checkbox": {
84
- "equals": true
85
- }
86
- },
87
- {
88
- "property": "Cost of next trip",
89
- "number": {
90
- "greater_than_or_equal_to": 2
91
- }
92
- }
93
- ]
94
- },
95
- "sorts": [
96
- {
97
- "property": "Last ordered",
98
- "direction": "ascending"
99
- }
100
- ]
101
- })
102
- ```
103
-
104
- ### Pages
105
-
106
- #### pages#retrieve
107
-
108
- [API reference](https://developers.notion.com/reference/get-page)
109
-
110
- ```rb
111
- client.pages.retrieve("b55c9c91-384d-452b-81db-d1ef79372b75")
112
- ```
113
-
114
- #### pages#create
115
-
116
- [API reference](https://developers.notion.com/reference/post-page)
117
-
118
- ```rb
119
- client.pages.create({
120
- "parent": { "database_id": "48f8fee9cd794180bc2fec0398253067" },
121
- "properties": {
122
- "Name": {
123
- "title": [
124
- {
125
- "text": {
126
- "content": "Tuscan Kale"
127
- }
128
- }
129
- ]
130
- },
131
- "Description": {
132
- "rich_text": [
133
- {
134
- "text": {
135
- "content": "A dark green leafy vegetable"
136
- }
137
- }
138
- ]
139
- },
140
- "Food group": {
141
- "select": {
142
- "name": "Vegetable"
143
- }
144
- },
145
- "Price": { "number": 2.5 }
146
- },
147
- "children": []
148
- })
149
- ```
150
-
151
- #### pages#update
152
-
153
- [API reference](https://developers.notion.com/reference/patch-page)
154
-
155
- ```rb
156
- client.pages.update("b55c9c91-384d-452b-81db-d1ef79372b75", {
157
- "properties": {
158
- "In stock": { "checkbox": true }
159
- }
160
- })
161
- ```
162
-
163
- ### Blocks
164
-
165
- #### blocks#children#list
166
-
167
- [API reference](https://developers.notion.com/reference/get-block-children)
168
-
169
- ```rb
170
- client.blocks.children.list("b55c9c91-384d-452b-81db-d1ef79372b75", {
171
- page_size: 100
172
- })
173
- ```
174
-
175
- #### blocks#children#append
176
-
177
- [API reference](https://developers.notion.com/reference/patch-block-children)
178
-
179
- ```rb
180
- client.blocks.children.append("b54c9c91-384d-452b-81db-d1ef79372b75", {
181
- "children": [
182
- {
183
- "object": "block",
184
- "type": "heading_1",
185
- "heading_1": {
186
- "text": [{ "type": "text", "text": { "content": "Lacinato kale" } }]
187
- }
188
- },
189
- {
190
- "object": "block",
191
- "type": "paragraph",
192
- "paragraph": {
193
- "text": [
194
- {
195
- "type": "text",
196
- "text": {
197
- "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.",
198
- "link": { "url": "https://en.wikipedia.org/wiki/Lacinato_kale" }
199
- }
200
- }
201
- ]
202
- }
203
- }
204
- ]
205
- })
206
- ```
207
-
208
- ### Users
209
-
210
- #### users#retrieve
211
-
212
- [API reference](https://developers.notion.com/reference/get-user)
213
-
214
- ```rb
215
- client.users.retrieve("d40e767c-d7af-4b18-a86d-55c61f1e39a4")
216
- ```
217
-
218
- #### users#list
219
-
220
- [API reference](https://developers.notion.com/reference/get-users)
221
-
222
- ```rb
223
- client.users.list
224
- ```
225
-
226
- ### Search
227
-
228
- [API reference](https://developers.notion.com/reference/post-search)
229
-
230
- #### #search
231
-
232
- ```rb
233
- client.search({
234
- "query":"External tasks",
235
- "sort":{
236
- "direction":"ascending",
237
- "timestamp":"last_edited_time"
238
- }
239
- }
240
- )
241
- ```
242
-
243
- ## Development
244
-
245
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
246
-
247
- Before using `bin/console` you need to create a new file, `.env`, at the root project directory. This will enable you to run commands directly against your [Notion integration](https://developers.notion.com/docs/getting-started).
248
-
249
- ```
250
- cat > .env <<EOF
251
- API_SECRET=<YOUR NOTION API SECRET HERE>
252
- EOF
253
- ```
254
-
255
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
256
-
257
- ## Contributing
258
-
259
- Bug reports and pull requests are welcome on GitHub at https://github.com/mgmarlow/notion-sdk-ruby.
260
-
261
- ## License
262
-
263
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
1
+ # Notion Ruby SDK
2
+
3
+ [![ci](https://github.com/mgmarlow/notion-sdk-ruby/actions/workflows/ci.yml/badge.svg)](https://github.com/mgmarlow/notion-sdk-ruby/actions/workflows/ci.yml)
4
+ [![Gem Version](https://badge.fury.io/rb/notion-sdk-ruby.svg)](https://badge.fury.io/rb/notion-sdk-ruby)
5
+
6
+ Unofficial Ruby client for the [Notion APIs](https://developers.notion.com/).
7
+
8
+ - [Notion Ruby SDK](#notion-ruby-sdk)
9
+ - [Installation](#installation)
10
+ - [Usage](#usage)
11
+ - [API reference](#api-reference)
12
+ - [Databases](#databases)
13
+ - [databases#retrieve](#databasesretrieve)
14
+ - [databases#list](#databaseslist)
15
+ - [databases#query](#databasesquery)
16
+ - [databases#create](#databasescreate)
17
+ - [databases#update](#databasesupdate)
18
+ - [Pages](#pages)
19
+ - [pages#retrieve](#pagesretrieve)
20
+ - [pages#create](#pagescreate)
21
+ - [pages#update](#pagesupdate)
22
+ - [Blocks](#blocks)
23
+ - [blocks#retrieve](#blocksretrieve)
24
+ - [blocks#update](#blocksupdate)
25
+ - [blocks#children#list](#blockschildrenlist)
26
+ - [blocks#children#append](#blockschildrenappend)
27
+ - [Users](#users)
28
+ - [users#retrieve](#usersretrieve)
29
+ - [users#list](#userslist)
30
+ - [Search](#search)
31
+ - [#search](#search-1)
32
+ - [Development](#development)
33
+ - [Contributing](#contributing)
34
+ - [License](#license)
35
+
36
+ ## Installation
37
+
38
+ Add this line to your application's Gemfile:
39
+
40
+ ```ruby
41
+ gem 'notion-sdk-ruby'
42
+ ```
43
+
44
+ And then execute:
45
+
46
+ $ bundle install
47
+
48
+ ## Usage
49
+
50
+ Initialize `Notion::Client` with your app's [integration secret](https://developers.notion.com/docs/getting-started#create-a-new-integration).
51
+
52
+ ```rb
53
+ require "notion-sdk-ruby"
54
+ client = Notion::Client.new(token: ENV["NOTION_API_SECRET"])
55
+ ```
56
+
57
+ ## API reference
58
+
59
+ ### Databases
60
+
61
+ #### databases#retrieve
62
+
63
+ [API reference](https://developers.notion.com/reference/get-database)
64
+
65
+ ```rb
66
+ client.databases.retrieve("668d797c-76fa-4934-9b05-ad288df2d136")
67
+ ```
68
+
69
+ #### databases#list
70
+
71
+ [API reference](https://developers.notion.com/reference/get-databases)
72
+
73
+ ```rb
74
+ client.databases.list
75
+ ```
76
+
77
+ #### databases#query
78
+
79
+ [API reference](https://developers.notion.com/reference/post-database-query)
80
+
81
+ ```rb
82
+ client.databases.query("668d797c-76fa-4934-9b05-ad288df2d136", {
83
+ filter: {
84
+ or: [
85
+ {
86
+ property: "In stock",
87
+ checkbox: {
88
+ equals: true
89
+ }
90
+ },
91
+ {
92
+ property: "Cost of next trip",
93
+ number: {
94
+ greater_than_or_equal_to: 2
95
+ }
96
+ }
97
+ ]
98
+ },
99
+ sorts: [
100
+ {
101
+ property: "Last ordered",
102
+ direction: "ascending"
103
+ }
104
+ ]
105
+ })
106
+ ```
107
+
108
+ #### databases#create
109
+
110
+ [API reference](https://developers.notion.com/reference/create-a-database)
111
+
112
+ ```rb
113
+ client.databases.create({
114
+ parent: {
115
+ type: "page_id",
116
+ page_id: "98ad959b-2b6a-4774-80ee-00246fb0ea9b"
117
+ },
118
+ title: [
119
+ {
120
+ type: "text",
121
+ text: {
122
+ content: "Grocery List",
123
+ link: null
124
+ }
125
+ }
126
+ ],
127
+ properties: {
128
+ Name: {
129
+ title: {}
130
+ }
131
+ }
132
+ })
133
+ ```
134
+
135
+ #### databases#update
136
+
137
+ [API reference](https://developers.notion.com/reference/update-a-database)
138
+
139
+ ```rb
140
+ client.databases.update("668d797c-76fa-4934-9b05-ad288df2d136", {
141
+ title: [
142
+ {
143
+ type: "text",
144
+ text: {
145
+ content: "Grocery List",
146
+ link: null
147
+ }
148
+ }
149
+ ],
150
+ properties: {
151
+ Name: {
152
+ title: {}
153
+ }
154
+ }
155
+ })
156
+ ```
157
+
158
+ ### Pages
159
+
160
+ #### pages#retrieve
161
+
162
+ [API reference](https://developers.notion.com/reference/get-page)
163
+
164
+ ```rb
165
+ client.pages.retrieve("b55c9c91-384d-452b-81db-d1ef79372b75")
166
+ ```
167
+
168
+ #### pages#create
169
+
170
+ [API reference](https://developers.notion.com/reference/post-page)
171
+
172
+ ```rb
173
+ client.pages.create({
174
+ parent: { database_id: "48f8fee9cd794180bc2fec0398253067" },
175
+ properties: {
176
+ Name: {
177
+ title: [
178
+ {
179
+ text: {
180
+ content: "Tuscan Kale"
181
+ }
182
+ }
183
+ ]
184
+ },
185
+ Description: {
186
+ rich_text: [
187
+ {
188
+ text: {
189
+ content: "A dark green leafy vegetable"
190
+ }
191
+ }
192
+ ]
193
+ },
194
+ Food group: {
195
+ select: {
196
+ name: "Vegetable"
197
+ }
198
+ },
199
+ Price: { number: 2.5 }
200
+ },
201
+ children: []
202
+ })
203
+ ```
204
+
205
+ #### pages#update
206
+
207
+ [API reference](https://developers.notion.com/reference/patch-page)
208
+
209
+ ```rb
210
+ client.pages.update("b55c9c91-384d-452b-81db-d1ef79372b75", {
211
+ properties: {
212
+ "In stock": { checkbox: true }
213
+ }
214
+ })
215
+ ```
216
+
217
+ ### Blocks
218
+
219
+ #### blocks#retrieve
220
+
221
+ [API reference](https://developers.notion.com/reference/retrieve-a-block)
222
+
223
+ ```rb
224
+ client.blocks.retrieve("b55c9c91-384d-452b-81db-d1ef79372b75")
225
+ ```
226
+
227
+ #### blocks#update
228
+
229
+ [API reference](https://developers.notion.com/reference/update-a-block)
230
+
231
+ ```rb
232
+ client.blocks.update("b55c9c91-384d-452b-81db-d1ef79372b75", {
233
+ to_do: {
234
+ text: [{
235
+ text: { content: "Lacinato kale" }
236
+ }],
237
+ checked: false
238
+ }
239
+ })
240
+ ```
241
+
242
+ #### blocks#children#list
243
+
244
+ [API reference](https://developers.notion.com/reference/get-block-children)
245
+
246
+ ```rb
247
+ client.blocks.children.list("b55c9c91-384d-452b-81db-d1ef79372b75", {
248
+ page_size: 100
249
+ })
250
+ ```
251
+
252
+ #### blocks#children#append
253
+
254
+ [API reference](https://developers.notion.com/reference/patch-block-children)
255
+
256
+ ```rb
257
+ client.blocks.children.append("b54c9c91-384d-452b-81db-d1ef79372b75", {
258
+ children: [
259
+ {
260
+ object: "block",
261
+ type: "heading_1",
262
+ heading_1: {
263
+ text: [{ type: "text", text: { content: "Lacinato kale" } }]
264
+ }
265
+ },
266
+ {
267
+ object: "block",
268
+ type: "paragraph",
269
+ paragraph: {
270
+ text: [
271
+ {
272
+ type: "text",
273
+ text: {
274
+ 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.",
275
+ link: { url: "https://en.wikipedia.org/wiki/Lacinato_kale" }
276
+ }
277
+ }
278
+ ]
279
+ }
280
+ }
281
+ ]
282
+ })
283
+ ```
284
+
285
+ ### Users
286
+
287
+ #### users#retrieve
288
+
289
+ [API reference](https://developers.notion.com/reference/get-user)
290
+
291
+ ```rb
292
+ client.users.retrieve("d40e767c-d7af-4b18-a86d-55c61f1e39a4")
293
+ ```
294
+
295
+ #### users#list
296
+
297
+ [API reference](https://developers.notion.com/reference/get-users)
298
+
299
+ ```rb
300
+ client.users.list
301
+ ```
302
+
303
+ ### Search
304
+
305
+ [API reference](https://developers.notion.com/reference/post-search)
306
+
307
+ #### #search
308
+
309
+ ```rb
310
+ client.search({
311
+ query: "External tasks",
312
+ sort: {
313
+ direction: "ascending",
314
+ timestamp: "last_edited_time"
315
+ }
316
+ })
317
+ ```
318
+
319
+ ## Development
320
+
321
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
322
+
323
+ Before using `bin/console` you need to create a new file, `.env`, at the root project directory. This will enable you to run commands directly against your [Notion integration](https://developers.notion.com/docs/getting-started).
324
+
325
+ ```
326
+ cat > .env <<EOF
327
+ API_SECRET=<YOUR NOTION API SECRET HERE>
328
+ EOF
329
+ ```
330
+
331
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
332
+
333
+ ## Contributing
334
+
335
+ Bug reports and pull requests are welcome on GitHub at https://github.com/mgmarlow/notion-sdk-ruby.
336
+
337
+ ## License
338
+
339
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
- require "standard/rake"
4
-
5
- RSpec::Core::RakeTask.new(:spec)
6
-
7
- task default: [:spec, :standard]
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+ require "standard/rake"
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task default: [:spec, :standard]
data/bin/console CHANGED
@@ -1,11 +1,11 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "pry"
5
- require 'dotenv/load'
6
-
7
- require "notion-sdk-ruby"
8
-
9
- $client = Notion::Client.new(token: ENV["API_SECRET"])
10
-
11
- Pry.start
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "pry"
5
+ require 'dotenv/load'
6
+
7
+ require "notion-sdk-ruby"
8
+
9
+ $client = Notion::Client.new(token: ENV["API_SECRET"])
10
+
11
+ Pry.start
data/bin/setup CHANGED
@@ -1,8 +1,8 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here