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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +228 -211
- data/bin/console +12 -11
- data/lib/notion-sdk-ruby.rb +20 -7
- data/lib/notion-sdk-ruby/client.rb +18 -5
- data/lib/notion-sdk-ruby/config.rb +5 -0
- data/lib/notion-sdk-ruby/error.rb +52 -0
- data/lib/notion-sdk-ruby/operations/search.rb +9 -0
- data/lib/notion-sdk-ruby/request_client.rb +49 -0
- data/lib/notion-sdk-ruby/resources/blocks.rb +17 -0
- data/lib/notion-sdk-ruby/resources/databases.rb +15 -0
- data/lib/notion-sdk-ruby/resources/pages.rb +15 -0
- data/lib/notion-sdk-ruby/resources/users.rb +11 -0
- data/lib/notion-sdk-ruby/version.rb +1 -1
- metadata +10 -8
- data/lib/notion-sdk-ruby/endpoints.rb +0 -9
- data/lib/notion-sdk-ruby/endpoints/blocks.rb +0 -13
- data/lib/notion-sdk-ruby/endpoints/databases.rb +0 -17
- data/lib/notion-sdk-ruby/endpoints/pages.rb +0 -17
- data/lib/notion-sdk-ruby/endpoints/search.rb +0 -9
- data/lib/notion-sdk-ruby/endpoints/users.rb +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 646301fd9a326d4b9d74cb514b948f85ff38dc0c7f001edd5c94285510029088
|
4
|
+
data.tar.gz: a544ddbd17c26ba618082eb04dc2e3e268da12b1b9d729fbf9109c8d642fc803
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 256824b18cfead3ab2630a96906022a5d8e936c3323824c5dd72e6605592c67fc2fa94d59f71796365e3639ced885b7f3344f6f39300fa7b74211be1ee618506
|
7
|
+
data.tar.gz: e7ec55aea773b32cead4f0ce0a788435abdd7e45f7a7050f9541a0c3514d612786f4be6661fa1fb35ddc904ca8961d363120d02a57035e14683f3c6d7c20eb80
|
data/Gemfile.lock
CHANGED
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
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
"
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
"
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
"
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
},
|
113
|
-
"
|
114
|
-
|
115
|
-
|
116
|
-
}
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
```
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
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
|
-
|
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
|
data/lib/notion-sdk-ruby.rb
CHANGED
@@ -1,13 +1,26 @@
|
|
1
1
|
require "httparty"
|
2
|
+
require "forwardable"
|
3
|
+
|
2
4
|
require "notion-sdk-ruby/version"
|
3
|
-
|
4
|
-
require "notion-sdk-ruby/
|
5
|
-
require "notion-sdk-ruby/
|
6
|
-
require "notion-sdk-ruby/
|
7
|
-
require "notion-sdk-ruby/
|
8
|
-
require "notion-sdk-ruby/
|
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
|
-
|
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
|
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
|
-
|
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,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,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
|
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.
|
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-
|
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/
|
133
|
-
- lib/notion-sdk-ruby/
|
134
|
-
- lib/notion-sdk-ruby/
|
135
|
-
- lib/notion-sdk-ruby/
|
136
|
-
- lib/notion-sdk-ruby/
|
137
|
-
- lib/notion-sdk-ruby/
|
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,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
|