notion-sdk-ruby 0.2.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f7e21c20b56990d0f42d1df0130e4e3f3d7835727d4802cd230b7bb5daaa4109
4
- data.tar.gz: 1ad409bdc5168dac0f604e62efda59ca5b1d343a353b6492f42f9daaf650fe57
3
+ metadata.gz: 646301fd9a326d4b9d74cb514b948f85ff38dc0c7f001edd5c94285510029088
4
+ data.tar.gz: a544ddbd17c26ba618082eb04dc2e3e268da12b1b9d729fbf9109c8d642fc803
5
5
  SHA512:
6
- metadata.gz: cd38bbbb96dd0c1fbf80bf419032a9e00be069de0c5e74ed921f1d6fb06846064d773fe0ad046cd2b8f7d38b9496247a307f48ac485c720e4877d20b52b9b1b0
7
- data.tar.gz: 3beaf308945c7e566a74a63068f078bc211e07a74e0d677beb0788c2073c3d360f583204648bb522f54f012fad877e4dd92e2c0ebf585afda878bc2fd2071d9f
6
+ metadata.gz: 256824b18cfead3ab2630a96906022a5d8e936c3323824c5dd72e6605592c67fc2fa94d59f71796365e3639ced885b7f3344f6f39300fa7b74211be1ee618506
7
+ data.tar.gz: e7ec55aea773b32cead4f0ce0a788435abdd7e45f7a7050f9541a0c3514d612786f4be6661fa1fb35ddc904ca8961d363120d02a57035e14683f3c6d7c20eb80
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- notion-sdk-ruby (0.2.3)
4
+ notion-sdk-ruby (0.3.0)
5
5
  httparty (~> 0.18.1)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -1,211 +1,228 @@
1
- # Notion Ruby SDK
2
-
3
- Unofficial Ruby client for the [Notion APIs](https://developers.notion.com/).
4
-
5
- ## Installation
6
-
7
- Add this line to your application's Gemfile:
8
-
9
- ```ruby
10
- gem 'notion-sdk-ruby'
11
- ```
12
-
13
- And then execute:
14
-
15
- $ bundle install
16
-
17
- Or install it yourself as:
18
-
19
- $ gem install notion-sdk-ruby
20
-
21
- ## Usage
22
-
23
- Initialize `Notion::Client` with your app's [integration secret](https://developers.notion.com/docs/getting-started#create-a-new-integration).
24
-
25
- ```rb
26
- require "notion-sdk-ruby"
27
- client = Notion::Client.new(token: ENV["NOTION_API_SECRET"])
28
-
29
- # get users
30
- client.get_users
31
- ```
32
-
33
- ### Databases
34
-
35
- #### #get_database
36
-
37
- ```rb
38
- client.get_database("668d797c-76fa-4934-9b05-ad288df2d136")
39
- ```
40
-
41
- #### #get_databases
42
-
43
- ```rb
44
- client.get_databases
45
- ```
46
-
47
- #### #query_database
48
-
49
- ```rb
50
- client.query_database("668d797c-76fa-4934-9b05-ad288df2d136", {
51
- "filter": {
52
- "or": [
53
- {
54
- "property": "In stock",
55
- "checkbox": {
56
- "equals": true
57
- }
58
- },
59
- {
60
- "property": "Cost of next trip",
61
- "number": {
62
- "greater_than_or_equal_to": 2
63
- }
64
- }
65
- ]
66
- },
67
- "sorts": [
68
- {
69
- "property": "Last ordered",
70
- "direction": "ascending"
71
- }
72
- ]
73
- })
74
- ```
75
-
76
- ### Pages
77
-
78
- #### #get_page
79
-
80
- ```rb
81
- client.get_page("b55c9c91-384d-452b-81db-d1ef79372b75")
82
- ```
83
-
84
- #### #create_page
85
-
86
- ```rb
87
- client.create_page({
88
- "parent": { "database_id": "48f8fee9cd794180bc2fec0398253067" },
89
- "properties": {
90
- "Name": {
91
- "title": [
92
- {
93
- "text": {
94
- "content": "Tuscan Kale"
95
- }
96
- }
97
- ]
98
- },
99
- "Description": {
100
- "rich_text": [
101
- {
102
- "text": {
103
- "content": "A dark green leafy vegetable"
104
- }
105
- }
106
- ]
107
- },
108
- "Food group": {
109
- "select": {
110
- "name": "Vegetable"
111
- }
112
- },
113
- "Price": { "number": 2.5 }
114
- },
115
- "children": []
116
- })
117
- ```
118
-
119
- #### #update_page
120
-
121
- ```rb
122
- client.update_page("b55c9c91-384d-452b-81db-d1ef79372b75", {
123
- "properties": {
124
- "In stock": { "checkbox": true }
125
- }
126
- })
127
- ```
128
-
129
- ### Blocks
130
-
131
- #### #get_block_children
132
-
133
- ```rb
134
- client.get_block_children("b55c9c91-384d-452b-81db-d1ef79372b75", {
135
- page_size: 100
136
- })
137
- ```
138
-
139
- #### #append_block_children
140
-
141
- ```rb
142
- client.append_block_children("b54c9c91-384d-452b-81db-d1ef79372b75", {
143
- "children": [
144
- {
145
- "object": "block",
146
- "type": "heading_1",
147
- "heading_1": {
148
- "text": [{ "type": "text", "text": { "content": "Lacinato kale" } }]
149
- }
150
- },
151
- {
152
- "object": "block",
153
- "type": "paragraph",
154
- "paragraph": {
155
- "text": [
156
- {
157
- "type": "text",
158
- "text": {
159
- "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.",
160
- "link": { "url": "https://en.wikipedia.org/wiki/Lacinato_kale" }
161
- }
162
- }
163
- ]
164
- }
165
- }
166
- ]
167
- })
168
- ```
169
-
170
- ### Users
171
-
172
- #### #get_user
173
-
174
- ```rb
175
- client.get_user("d40e767c-d7af-4b18-a86d-55c61f1e39a4")
176
- ```
177
-
178
- #### #get_users
179
-
180
- ```rb
181
- client.get_users
182
- ```
183
-
184
- ### Search
185
-
186
- #### #search
187
-
188
- ```rb
189
- client.search({
190
- "query":"External tasks",
191
- "sort":{
192
- "direction":"ascending",
193
- "timestamp":"last_edited_time"
194
- }
195
- }
196
- )
197
- ```
198
-
199
- ## Development
200
-
201
- 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.
202
-
203
- 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).
204
-
205
- ## Contributing
206
-
207
- Bug reports and pull requests are welcome on GitHub at https://github.com/mgmarlow/notion-sdk-ruby.
208
-
209
- ## License
210
-
211
- 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
+ Unofficial Ruby client for the [Notion APIs](https://developers.notion.com/).
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'notion-sdk-ruby'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+ ## Usage
18
+
19
+ Initialize `Notion::Client` with your app's [integration secret](https://developers.notion.com/docs/getting-started#create-a-new-integration).
20
+
21
+ ```rb
22
+ require "notion-sdk-ruby"
23
+ client = Notion::Client.new(token: ENV["NOTION_API_SECRET"])
24
+ ```
25
+
26
+ ## API reference
27
+
28
+ ### Databases
29
+
30
+ #### databases#retrieve
31
+
32
+ [API reference](https://developers.notion.com/reference/get-database)
33
+
34
+ ```rb
35
+ client.databases.retrieve("668d797c-76fa-4934-9b05-ad288df2d136")
36
+ ```
37
+
38
+ #### databases#list
39
+
40
+ [API reference](https://developers.notion.com/reference/get-databases)
41
+
42
+ ```rb
43
+ client.databases.list
44
+ ```
45
+
46
+ #### databases#query
47
+
48
+ [API reference](https://developers.notion.com/reference/post-database-query)
49
+
50
+ ```rb
51
+ client.databases.query("668d797c-76fa-4934-9b05-ad288df2d136", {
52
+ "filter": {
53
+ "or": [
54
+ {
55
+ "property": "In stock",
56
+ "checkbox": {
57
+ "equals": true
58
+ }
59
+ },
60
+ {
61
+ "property": "Cost of next trip",
62
+ "number": {
63
+ "greater_than_or_equal_to": 2
64
+ }
65
+ }
66
+ ]
67
+ },
68
+ "sorts": [
69
+ {
70
+ "property": "Last ordered",
71
+ "direction": "ascending"
72
+ }
73
+ ]
74
+ })
75
+ ```
76
+
77
+ ### Pages
78
+
79
+ #### pages#retrieve
80
+
81
+ [API reference](https://developers.notion.com/reference/get-page)
82
+
83
+ ```rb
84
+ client.pages.retrieve("b55c9c91-384d-452b-81db-d1ef79372b75")
85
+ ```
86
+
87
+ #### pages#create
88
+
89
+ [API reference](https://developers.notion.com/reference/post-page)
90
+
91
+ ```rb
92
+ client.pages.create({
93
+ "parent": { "database_id": "48f8fee9cd794180bc2fec0398253067" },
94
+ "properties": {
95
+ "Name": {
96
+ "title": [
97
+ {
98
+ "text": {
99
+ "content": "Tuscan Kale"
100
+ }
101
+ }
102
+ ]
103
+ },
104
+ "Description": {
105
+ "rich_text": [
106
+ {
107
+ "text": {
108
+ "content": "A dark green leafy vegetable"
109
+ }
110
+ }
111
+ ]
112
+ },
113
+ "Food group": {
114
+ "select": {
115
+ "name": "Vegetable"
116
+ }
117
+ },
118
+ "Price": { "number": 2.5 }
119
+ },
120
+ "children": []
121
+ })
122
+ ```
123
+
124
+ #### pages#update
125
+
126
+ [API reference](https://developers.notion.com/reference/patch-page)
127
+
128
+ ```rb
129
+ client.pages.update("b55c9c91-384d-452b-81db-d1ef79372b75", {
130
+ "properties": {
131
+ "In stock": { "checkbox": true }
132
+ }
133
+ })
134
+ ```
135
+
136
+ ### Blocks
137
+
138
+ #### blocks#children#list
139
+
140
+ [API reference](https://developers.notion.com/reference/get-block-children)
141
+
142
+ ```rb
143
+ client.blocks.children.list("b55c9c91-384d-452b-81db-d1ef79372b75", {
144
+ page_size: 100
145
+ })
146
+ ```
147
+
148
+ #### blocks#children#append
149
+
150
+ [API reference](https://developers.notion.com/reference/patch-block-children)
151
+
152
+ ```rb
153
+ client.blocks.children.append("b54c9c91-384d-452b-81db-d1ef79372b75", {
154
+ "children": [
155
+ {
156
+ "object": "block",
157
+ "type": "heading_1",
158
+ "heading_1": {
159
+ "text": [{ "type": "text", "text": { "content": "Lacinato kale" } }]
160
+ }
161
+ },
162
+ {
163
+ "object": "block",
164
+ "type": "paragraph",
165
+ "paragraph": {
166
+ "text": [
167
+ {
168
+ "type": "text",
169
+ "text": {
170
+ "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.",
171
+ "link": { "url": "https://en.wikipedia.org/wiki/Lacinato_kale" }
172
+ }
173
+ }
174
+ ]
175
+ }
176
+ }
177
+ ]
178
+ })
179
+ ```
180
+
181
+ ### Users
182
+
183
+ #### users#retrieve
184
+
185
+ [API reference](https://developers.notion.com/reference/get-user)
186
+
187
+ ```rb
188
+ client.users.retrieve("d40e767c-d7af-4b18-a86d-55c61f1e39a4")
189
+ ```
190
+
191
+ #### users#list
192
+
193
+ [API reference](https://developers.notion.com/reference/get-users)
194
+
195
+ ```rb
196
+ client.users.list
197
+ ```
198
+
199
+ ### Search
200
+
201
+ [API reference](https://developers.notion.com/reference/post-search)
202
+
203
+ #### #search
204
+
205
+ ```rb
206
+ client.search({
207
+ "query":"External tasks",
208
+ "sort":{
209
+ "direction":"ascending",
210
+ "timestamp":"last_edited_time"
211
+ }
212
+ }
213
+ )
214
+ ```
215
+
216
+ ## Development
217
+
218
+ 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.
219
+
220
+ 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).
221
+
222
+ ## Contributing
223
+
224
+ Bug reports and pull requests are welcome on GitHub at https://github.com/mgmarlow/notion-sdk-ruby.
225
+
226
+ ## License
227
+
228
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/bin/console CHANGED
@@ -1,11 +1,12 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "pry"
5
- require 'dotenv/load'
6
-
7
- require "notion"
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
+ $client2 = Notion::Client.new(token: ENV["API_SECRET"])
11
+
12
+ Pry.start
@@ -1,13 +1,26 @@
1
1
  require "httparty"
2
+ require "forwardable"
3
+
2
4
  require "notion-sdk-ruby/version"
3
- require "notion-sdk-ruby/endpoints/blocks"
4
- require "notion-sdk-ruby/endpoints/databases"
5
- require "notion-sdk-ruby/endpoints/pages"
6
- require "notion-sdk-ruby/endpoints/search"
7
- require "notion-sdk-ruby/endpoints/users"
8
- require "notion-sdk-ruby/endpoints"
5
+
6
+ require "notion-sdk-ruby/config"
7
+ require "notion-sdk-ruby/resources/blocks"
8
+ require "notion-sdk-ruby/resources/databases"
9
+ require "notion-sdk-ruby/resources/pages"
10
+ require "notion-sdk-ruby/resources/users"
11
+ require "notion-sdk-ruby/operations/search"
12
+ require "notion-sdk-ruby/error"
13
+ require "notion-sdk-ruby/request_client"
9
14
  require "notion-sdk-ruby/client"
10
15
 
11
16
  module Notion
12
- class Error < StandardError; end
17
+ @config = Config.new
18
+
19
+ class << self
20
+ extend Forwardable
21
+
22
+ attr_reader :config
23
+
24
+ def_delegators :@config, :api_token, :api_token=
25
+ end
13
26
  end
@@ -1,12 +1,25 @@
1
1
  module Notion
2
2
  class Client
3
- include Endpoints
4
- include HTTParty
5
- headers 'Content-Type': "application/json"
6
- base_uri "https://api.notion.com"
3
+ include Operations::Search
7
4
 
8
5
  def initialize(token:)
9
- self.class.headers({Authorization: "Bearer #{token}"})
6
+ Notion.api_token = token
7
+ end
8
+
9
+ def blocks
10
+ Blocks.new
11
+ end
12
+
13
+ def databases
14
+ Databases.new
15
+ end
16
+
17
+ def pages
18
+ Pages.new
19
+ end
20
+
21
+ def users
22
+ Users.new
10
23
  end
11
24
  end
12
25
  end
@@ -0,0 +1,5 @@
1
+ module Notion
2
+ class Config
3
+ attr_accessor :api_token
4
+ end
5
+ end
@@ -0,0 +1,52 @@
1
+ # Sourced from notion-sdk-js:
2
+ # https://github.com/makenotion/notion-sdk-js/blob/main/src/errors.ts
3
+ module Notion
4
+ API_ERROR_CODE = {
5
+ unauthorized: "unauthorized",
6
+ restricted_resource: "restricted_resource",
7
+ object_not_found: "object_not_found",
8
+ rate_limited: "rate_limited",
9
+ invalid_json: "invalid_json",
10
+ invalid_request_url: "invalid_request_url",
11
+ invalid_request: "invalid_request",
12
+ validation_error: "validation_error",
13
+ conflict_error: "conflict_error",
14
+ internal_server_error: "internal_server_error",
15
+ service_unavailable: "service_unavailable"
16
+ }
17
+
18
+ class ErrorFactory
19
+ def self.create(error = {})
20
+ return NotionError.new("Unknown error.") if error["message"].nil?
21
+
22
+ if API_ERROR_CODE.value?(error["code"])
23
+ APIResponseError.new(error["message"], body: error)
24
+ elsif error["request"] && error["response"] && error["timings"]
25
+ HTTPResponseError.new(error["message"], body: error)
26
+ elsif error["request"] && error["timings"]
27
+ RequestTimeoutError.new(error["message"], body: error)
28
+ else
29
+ NotionError.new(error["message"])
30
+ end
31
+ end
32
+ end
33
+
34
+ class NotionError < StandardError
35
+ attr_reader :message, :body
36
+
37
+ def initialize(message = nil, body: nil)
38
+ @message = message
39
+ @body = body
40
+ end
41
+ end
42
+
43
+ class RequestTimeoutError < NotionError; end
44
+
45
+ class HTTPResponseError < NotionError; end
46
+
47
+ class APIResponseError < NotionError
48
+ def code
49
+ body["code"]
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,9 @@
1
+ module Notion
2
+ module Operations
3
+ module Search
4
+ def search(body)
5
+ RequestClient.active_client.post("/v1/search", body: body.to_json)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,49 @@
1
+ module Notion
2
+ class RequestClient
3
+ include HTTParty
4
+
5
+ base_uri "https://api.notion.com"
6
+ headers "Content-Type": "application/json"
7
+
8
+ def self.active_client
9
+ RequestClient.new(Notion.config)
10
+ end
11
+
12
+ def initialize(config)
13
+ self.class.headers Authorization: "Bearer #{config.api_token}"
14
+ end
15
+
16
+ def get(*args, &block)
17
+ response = self.class.get(*args, &block)
18
+ raise_on_failure(response)
19
+ end
20
+
21
+ def post(*args, &block)
22
+ response = self.class.post(*args, &block)
23
+ raise_on_failure(response)
24
+ end
25
+
26
+ def patch(*args, &block)
27
+ response = self.class.patch(*args, &block)
28
+ raise_on_failure(response)
29
+ end
30
+
31
+ def put(*args, &block)
32
+ response = self.class.put(*args, &block)
33
+ raise_on_failure(response)
34
+ end
35
+
36
+ def delete(*args, &block)
37
+ response = self.class.delete(*args, &block)
38
+ raise_on_failure(response)
39
+ end
40
+
41
+ def raise_on_failure(response)
42
+ if response.success?
43
+ response
44
+ else
45
+ raise ErrorFactory.create(response)
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,17 @@
1
+ module Notion
2
+ class Blocks
3
+ def children
4
+ Children.new
5
+ end
6
+ end
7
+
8
+ class Children
9
+ def list(block_id, query: {})
10
+ RequestClient.active_client.get("/v1/blocks/#{block_id}/children", query: query)
11
+ end
12
+
13
+ def append(block_id, body)
14
+ RequestClient.active_client.patch("/v1/blocks/#{block_id}/children", body: body.to_json)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,15 @@
1
+ module Notion
2
+ class Databases
3
+ def retrieve(id)
4
+ RequestClient.active_client.get("/v1/databases/#{id}")
5
+ end
6
+
7
+ def list
8
+ RequestClient.active_client.get("/v1/databases")
9
+ end
10
+
11
+ def query(id, body)
12
+ RequestClient.active_client.post("/v1/databases/#{id}/query", body: body.to_json)
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module Notion
2
+ class Pages
3
+ def retrieve(id)
4
+ RequestClient.active_client.get("/v1/pages/#{id}")
5
+ end
6
+
7
+ def create(body)
8
+ RequestClient.active_client.post("/v1/pages", body: body.to_json)
9
+ end
10
+
11
+ def update(id, body)
12
+ RequestClient.active_client.patch("/v1/pages/#{id}", body: body.to_json)
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,11 @@
1
+ module Notion
2
+ class Users
3
+ def list
4
+ RequestClient.active_client.get("/v1/users")
5
+ end
6
+
7
+ def retrieve(id)
8
+ RequestClient.active_client.get("/v1/users/#{id}")
9
+ end
10
+ end
11
+ end
@@ -1,3 +1,3 @@
1
1
  module Notion
2
- VERSION = "0.2.3"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: notion-sdk-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Graham Marlow
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-05-17 00:00:00.000000000 Z
11
+ date: 2021-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -129,12 +129,14 @@ files:
129
129
  - bin/setup
130
130
  - lib/notion-sdk-ruby.rb
131
131
  - lib/notion-sdk-ruby/client.rb
132
- - lib/notion-sdk-ruby/endpoints.rb
133
- - lib/notion-sdk-ruby/endpoints/blocks.rb
134
- - lib/notion-sdk-ruby/endpoints/databases.rb
135
- - lib/notion-sdk-ruby/endpoints/pages.rb
136
- - lib/notion-sdk-ruby/endpoints/search.rb
137
- - lib/notion-sdk-ruby/endpoints/users.rb
132
+ - lib/notion-sdk-ruby/config.rb
133
+ - lib/notion-sdk-ruby/error.rb
134
+ - lib/notion-sdk-ruby/operations/search.rb
135
+ - lib/notion-sdk-ruby/request_client.rb
136
+ - lib/notion-sdk-ruby/resources/blocks.rb
137
+ - lib/notion-sdk-ruby/resources/databases.rb
138
+ - lib/notion-sdk-ruby/resources/pages.rb
139
+ - lib/notion-sdk-ruby/resources/users.rb
138
140
  - lib/notion-sdk-ruby/version.rb
139
141
  - notion-sdk-ruby.gemspec
140
142
  homepage: https://github.com/mgmarlow/notion-sdk-ruby
@@ -1,9 +0,0 @@
1
- module Notion
2
- module Endpoints
3
- include Databases
4
- include Pages
5
- include Blocks
6
- include Users
7
- include Search
8
- end
9
- end
@@ -1,13 +0,0 @@
1
- module Notion
2
- module Endpoints
3
- module Blocks
4
- def get_block_children(id, params: {})
5
- self.class.get("/v1/blocks/#{id}/children", query: params)
6
- end
7
-
8
- def append_block_children(id, body)
9
- self.class.patch("/v1/blocks/#{id}/children", body: body.to_json)
10
- end
11
- end
12
- end
13
- end
@@ -1,17 +0,0 @@
1
- module Notion
2
- module Endpoints
3
- module Databases
4
- def get_database(id)
5
- self.class.get("/v1/databases/#{id}")
6
- end
7
-
8
- def get_databases
9
- self.class.get("/v1/databases")
10
- end
11
-
12
- def query_database(id, body)
13
- self.class.post("/v1/databases/#{id}/query", body: body.to_json)
14
- end
15
- end
16
- end
17
- end
@@ -1,17 +0,0 @@
1
- module Notion
2
- module Endpoints
3
- module Pages
4
- def get_page(id)
5
- self.class.get("/v1/pages/#{id}")
6
- end
7
-
8
- def create_page(body)
9
- self.class.post("/v1/pages", body: body.to_json)
10
- end
11
-
12
- def update_page(id, body)
13
- self.class.patch("/v1/pages/#{id}", body: body.to_json)
14
- end
15
- end
16
- end
17
- end
@@ -1,9 +0,0 @@
1
- module Notion
2
- module Endpoints
3
- module Search
4
- def search(body)
5
- self.class.post("/v1/search", body: body.to_json)
6
- end
7
- end
8
- end
9
- end
@@ -1,13 +0,0 @@
1
- module Notion
2
- module Endpoints
3
- module Users
4
- def get_users
5
- self.class.get("/v1/users")
6
- end
7
-
8
- def get_user(id)
9
- self.class.get("/v1/users/#{id}")
10
- end
11
- end
12
- end
13
- end