notion-ruby-client 1.0.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +2 -2
- data/.github/workflows/rubocop.yml +17 -0
- data/CHANGELOG.md +19 -0
- data/Gemfile.lock +14 -43
- data/README.md +47 -6
- data/lib/notion/api/endpoints/blocks.rb +8 -5
- data/lib/notion/api/endpoints/comments.rb +61 -0
- data/lib/notion/api/endpoints/databases.rb +5 -3
- data/lib/notion/api/endpoints/pages.rb +3 -2
- data/lib/notion/api/endpoints.rb +2 -0
- data/lib/notion/config.rb +2 -2
- data/lib/notion/faraday/connection.rb +4 -4
- data/lib/notion/faraday/request.rb +1 -1
- data/lib/notion/faraday/response/raise_error.rb +2 -2
- data/lib/notion/faraday/response/wrap_error.rb +2 -2
- data/lib/notion/version.rb +1 -1
- data/lib/notion-ruby-client.rb +2 -2
- data/notion-ruby-client.gemspec +3 -3
- data/spec/fixtures/notion/create_discussion_comment.yml +110 -0
- data/spec/fixtures/notion/create_page_comment.yml +110 -0
- data/spec/fixtures/notion/retrieve_comments.yml +106 -0
- data/spec/notion/api/endpoints/comments_spec.rb +49 -0
- metadata +24 -14
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8e4e676c9ca818a9cdcab31f6b085d00860bd74a102f668fdbe60cd209eaa442
|
|
4
|
+
data.tar.gz: 57c19debac66cc452d441ce718bdd4f1d410c2884ac1b422d75cfe0fa228b043
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fb1a69701d1b81d3209f9b4d36fb73e204d60fd6239be0b922fa7ea6ebf5ac24ec62bf7949cbfee34867ec5da706d1446ccde8a733d46eefad3fe6dda9cd2929
|
|
7
|
+
data.tar.gz: 38dde2575a611e67d4b6222f6c79299aef06869e72963765ba850ad567c1b36b77e5cb521c60c1ba9044537b6a4a7f781e276604e0770c61b69b96726596f97c
|
data/.github/workflows/ci.yml
CHANGED
|
@@ -4,7 +4,7 @@ jobs:
|
|
|
4
4
|
test:
|
|
5
5
|
strategy:
|
|
6
6
|
matrix:
|
|
7
|
-
ruby: [2.
|
|
7
|
+
ruby: [2.6, 2.7, '3.0', 3.1, 3.2]
|
|
8
8
|
runs-on: ubuntu-latest
|
|
9
9
|
steps:
|
|
10
10
|
- uses: actions/checkout@v2
|
|
@@ -12,4 +12,4 @@ jobs:
|
|
|
12
12
|
with:
|
|
13
13
|
bundler-cache: true
|
|
14
14
|
ruby-version: ${{ matrix.ruby }}
|
|
15
|
-
- run: bundle exec rake
|
|
15
|
+
- run: bundle exec rake spec
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
name: RuboCop
|
|
2
|
+
|
|
3
|
+
on: [push, pull_request]
|
|
4
|
+
|
|
5
|
+
jobs:
|
|
6
|
+
build:
|
|
7
|
+
runs-on: ubuntu-latest
|
|
8
|
+
|
|
9
|
+
steps:
|
|
10
|
+
- uses: actions/checkout@v3
|
|
11
|
+
- name: Set up Ruby
|
|
12
|
+
uses: ruby/setup-ruby@v1
|
|
13
|
+
with:
|
|
14
|
+
ruby-version: 2.7
|
|
15
|
+
bundler-cache: true # 'bundle install' and cache
|
|
16
|
+
- name: Run RuboCop
|
|
17
|
+
run: bundle exec rake rubocop
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
### 1.2.0 (2023-02-26)
|
|
2
|
+
|
|
3
|
+
#### New
|
|
4
|
+
|
|
5
|
+
- Add support for the following new endpoints (thanks @themoffatt!):
|
|
6
|
+
- [Create comment](https://developers.notion.com/reference/create-a-comment)
|
|
7
|
+
- [Retrieve comments](https://developers.notion.com/reference/retrieve-a-comment)
|
|
8
|
+
|
|
9
|
+
### 1.1.0 (2023-02-23)
|
|
10
|
+
|
|
11
|
+
#### Breaking changes
|
|
12
|
+
|
|
13
|
+
- Remove support for ruby 2.5
|
|
14
|
+
- Remove the `activesupport` dependency. Add `gem 'activesupport'` to your Gemfile if you required ActiveSupport via this library.
|
|
15
|
+
|
|
16
|
+
#### Other
|
|
17
|
+
|
|
18
|
+
- Upgrade Faraday to v2 (thanks @Tao-Galasse!)
|
|
19
|
+
|
|
1
20
|
### 1.0.0 (2022-03-30)
|
|
2
21
|
|
|
3
22
|
#### New
|
data/Gemfile.lock
CHANGED
|
@@ -1,62 +1,36 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
notion-ruby-client (1.
|
|
5
|
-
activesupport (>= 6)
|
|
4
|
+
notion-ruby-client (1.2.0)
|
|
6
5
|
dotenv
|
|
7
|
-
faraday (>=
|
|
8
|
-
|
|
6
|
+
faraday (>= 2.0)
|
|
7
|
+
faraday-mashify (>= 0.1.1)
|
|
8
|
+
faraday-multipart (>= 1.0.4)
|
|
9
9
|
hashie (~> 5)
|
|
10
10
|
|
|
11
11
|
GEM
|
|
12
12
|
remote: http://rubygems.org/
|
|
13
13
|
specs:
|
|
14
|
-
activesupport (6.1.5)
|
|
15
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
16
|
-
i18n (>= 1.6, < 2)
|
|
17
|
-
minitest (>= 5.1)
|
|
18
|
-
tzinfo (~> 2.0)
|
|
19
|
-
zeitwerk (~> 2.3)
|
|
20
14
|
addressable (2.8.0)
|
|
21
15
|
public_suffix (>= 2.0.2, < 5.0)
|
|
22
16
|
ast (2.4.2)
|
|
23
|
-
concurrent-ruby (1.1.10)
|
|
24
17
|
crack (0.4.5)
|
|
25
18
|
rexml
|
|
26
19
|
diff-lcs (1.4.4)
|
|
27
|
-
dotenv (2.
|
|
28
|
-
faraday (
|
|
29
|
-
faraday-
|
|
30
|
-
faraday-em_synchrony (~> 1.0)
|
|
31
|
-
faraday-excon (~> 1.1)
|
|
32
|
-
faraday-httpclient (~> 1.0)
|
|
33
|
-
faraday-multipart (~> 1.0)
|
|
34
|
-
faraday-net_http (~> 1.0)
|
|
35
|
-
faraday-net_http_persistent (~> 1.0)
|
|
36
|
-
faraday-patron (~> 1.0)
|
|
37
|
-
faraday-rack (~> 1.0)
|
|
38
|
-
faraday-retry (~> 1.0)
|
|
20
|
+
dotenv (2.8.1)
|
|
21
|
+
faraday (2.7.4)
|
|
22
|
+
faraday-net_http (>= 2.0, < 3.1)
|
|
39
23
|
ruby2_keywords (>= 0.0.4)
|
|
40
|
-
faraday-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
faraday-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
faraday-net_http (1.0.1)
|
|
47
|
-
faraday-net_http_persistent (1.2.0)
|
|
48
|
-
faraday-patron (1.0.0)
|
|
49
|
-
faraday-rack (1.0.0)
|
|
50
|
-
faraday-retry (1.0.3)
|
|
51
|
-
faraday_middleware (1.2.0)
|
|
52
|
-
faraday (~> 1.0)
|
|
24
|
+
faraday-mashify (0.1.1)
|
|
25
|
+
faraday (~> 2.0)
|
|
26
|
+
hashie
|
|
27
|
+
faraday-multipart (1.0.4)
|
|
28
|
+
multipart-post (~> 2)
|
|
29
|
+
faraday-net_http (3.0.2)
|
|
53
30
|
hashdiff (1.0.1)
|
|
54
31
|
hashie (5.0.0)
|
|
55
|
-
i18n (1.10.0)
|
|
56
|
-
concurrent-ruby (~> 1.0)
|
|
57
32
|
jaro_winkler (1.5.4)
|
|
58
|
-
|
|
59
|
-
multipart-post (2.1.1)
|
|
33
|
+
multipart-post (2.3.0)
|
|
60
34
|
parallel (1.20.1)
|
|
61
35
|
parser (3.0.1.1)
|
|
62
36
|
ast (~> 2.4.1)
|
|
@@ -92,15 +66,12 @@ GEM
|
|
|
92
66
|
ruby-progressbar (1.11.0)
|
|
93
67
|
ruby2_keywords (0.0.5)
|
|
94
68
|
timecop (0.9.4)
|
|
95
|
-
tzinfo (2.0.4)
|
|
96
|
-
concurrent-ruby (~> 1.0)
|
|
97
69
|
unicode-display_width (1.7.0)
|
|
98
70
|
vcr (6.0.0)
|
|
99
71
|
webmock (3.13.0)
|
|
100
72
|
addressable (>= 2.3.6)
|
|
101
73
|
crack (>= 0.3.2)
|
|
102
74
|
hashdiff (>= 0.4.0, < 2.0.0)
|
|
103
|
-
zeitwerk (2.5.4)
|
|
104
75
|
|
|
105
76
|
PLATFORMS
|
|
106
77
|
arm64-darwin-20
|
data/README.md
CHANGED
|
@@ -32,6 +32,10 @@ A Ruby client for the Notion API.
|
|
|
32
32
|
- [Delete a block](#delete-a-block)
|
|
33
33
|
- [Retrieve block children](#retrieve-block-children)
|
|
34
34
|
- [Append block children](#append-block-children)
|
|
35
|
+
- [Comments](#comments)
|
|
36
|
+
- [Retrieve comments](#retrieve-comments-from-a-page-or-block-by-id)
|
|
37
|
+
- [Create a comment on a page](#create-a-comment-on-a-page)
|
|
38
|
+
- [Create a comment on a discussion](#create-a-comment-on-a-discussion)
|
|
35
39
|
- [Users](#users)
|
|
36
40
|
- [Retrieve your token's bot user](#retrieve-your-tokens-bot-user)
|
|
37
41
|
- [Retrieve a user](#retrieve-a-user)
|
|
@@ -129,9 +133,9 @@ client.database_query(database_id: 'e383bcee-e0d8-4564-9c63-900d307abdb0') do |p
|
|
|
129
133
|
end
|
|
130
134
|
|
|
131
135
|
# Filter and sort the database
|
|
132
|
-
|
|
136
|
+
sorts = [
|
|
133
137
|
{
|
|
134
|
-
'
|
|
138
|
+
'timestamp': 'created_time',
|
|
135
139
|
'direction': 'ascending'
|
|
136
140
|
}
|
|
137
141
|
]
|
|
@@ -151,7 +155,7 @@ filter = {
|
|
|
151
155
|
}
|
|
152
156
|
]
|
|
153
157
|
}
|
|
154
|
-
client.database_query(database_id: 'e383bcee-e0d8-4564-9c63-900d307abdb0',
|
|
158
|
+
client.database_query(database_id: 'e383bcee-e0d8-4564-9c63-900d307abdb0', sorts: sorts, filter: filter)
|
|
155
159
|
```
|
|
156
160
|
|
|
157
161
|
See [Pagination](#pagination) for details about how to iterate through the list.
|
|
@@ -273,7 +277,7 @@ See the full endpoint documentation on [Notion Developers](https://developers.no
|
|
|
273
277
|
|
|
274
278
|
Creates a new page in the specified database or as a child of an existing page.
|
|
275
279
|
|
|
276
|
-
If the parent is a database, the [property values](https://developers.notion.com/reference-link/page-property-
|
|
280
|
+
If the parent is a database, the [property values](https://developers.notion.com/reference-link/page-property-values) of the new page in the properties parameter must conform to the parent [database](https://developers.notion.com/reference-link/database)'s property schema.
|
|
277
281
|
|
|
278
282
|
If the parent is a page, the only valid property is `title`.
|
|
279
283
|
|
|
@@ -314,14 +318,14 @@ children = [
|
|
|
314
318
|
'type': 'heading_2',
|
|
315
319
|
'heading_2': {
|
|
316
320
|
'rich_text': [{
|
|
317
|
-
'type
|
|
321
|
+
'type': 'text',
|
|
318
322
|
'text': { 'content': 'Lacinato kale' }
|
|
319
323
|
}]
|
|
320
324
|
}
|
|
321
325
|
},
|
|
322
326
|
{
|
|
323
327
|
'object': 'block',
|
|
324
|
-
'type
|
|
328
|
+
'type': 'paragraph',
|
|
325
329
|
'paragraph': {
|
|
326
330
|
'rich_text': [
|
|
327
331
|
{
|
|
@@ -463,6 +467,43 @@ client.block_append_children(block_id: 'b55c9c91-384d-452b-81db-d1ef79372b75', c
|
|
|
463
467
|
|
|
464
468
|
See the full endpoint documentation on [Notion Developers](https://developers.notion.com/reference/patch-block-children).
|
|
465
469
|
|
|
470
|
+
### Comments
|
|
471
|
+
|
|
472
|
+
#### Retrieve comments from a page or block by id
|
|
473
|
+
```ruby
|
|
474
|
+
client.retrieve_comments(block_id: '1a2f70ab26154dc7a838536a3f430af4')
|
|
475
|
+
```
|
|
476
|
+
#### Create a comment on a page
|
|
477
|
+
```ruby
|
|
478
|
+
options = {
|
|
479
|
+
parent: { page_id: '3e4bc91d36c74de595113b31c6fdb82c' },
|
|
480
|
+
rich_text: [
|
|
481
|
+
{
|
|
482
|
+
text: {
|
|
483
|
+
content: 'Hello world'
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
]
|
|
487
|
+
}
|
|
488
|
+
client.create_comment(options)
|
|
489
|
+
```
|
|
490
|
+
#### Create a comment on a discussion
|
|
491
|
+
```ruby
|
|
492
|
+
options = {
|
|
493
|
+
discussion_id: 'ea116af4839c410bb4ac242a18dc4392',
|
|
494
|
+
rich_text: [
|
|
495
|
+
{
|
|
496
|
+
text: {
|
|
497
|
+
content: 'Hello world'
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
]
|
|
501
|
+
}
|
|
502
|
+
client.create_comment(options)
|
|
503
|
+
```
|
|
504
|
+
|
|
505
|
+
See the full endpoint documention on [Notion Developers](https://developers.notion.com/reference/comment-object).
|
|
506
|
+
|
|
466
507
|
### Users
|
|
467
508
|
|
|
468
509
|
#### Retrieve your token's bot user
|
|
@@ -28,8 +28,9 @@ module Notion
|
|
|
28
28
|
# updated. Currently only text (for supported block types)
|
|
29
29
|
# and checked (for to_do blocks) fields can be updated.
|
|
30
30
|
def update_block(options = {})
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
block_id = options.delete(:block_id)
|
|
32
|
+
throw ArgumentError.new('Required arguments :block_id missing') if block_id.nil?
|
|
33
|
+
patch("blocks/#{block_id}", options)
|
|
33
34
|
end
|
|
34
35
|
|
|
35
36
|
#
|
|
@@ -67,7 +68,8 @@ module Notion
|
|
|
67
68
|
yield page
|
|
68
69
|
end
|
|
69
70
|
else
|
|
70
|
-
|
|
71
|
+
block_id = options.delete(:block_id)
|
|
72
|
+
get("blocks/#{block_id}/children", options)
|
|
71
73
|
end
|
|
72
74
|
end
|
|
73
75
|
|
|
@@ -88,8 +90,9 @@ module Notion
|
|
|
88
90
|
# @option options [[Object]] :children
|
|
89
91
|
# Children blocks to append
|
|
90
92
|
def block_append_children(options = {})
|
|
91
|
-
|
|
92
|
-
|
|
93
|
+
block_id = options.delete(:block_id)
|
|
94
|
+
throw ArgumentError.new('Required arguments :block_id missing') if block_id.nil?
|
|
95
|
+
patch("blocks/#{block_id}/children", options)
|
|
93
96
|
end
|
|
94
97
|
end
|
|
95
98
|
end
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
module Notion
|
|
3
|
+
module Api
|
|
4
|
+
module Endpoints
|
|
5
|
+
module Comments
|
|
6
|
+
#
|
|
7
|
+
# Retrieves a list of un-resolved Comment objects from a page or block.
|
|
8
|
+
#
|
|
9
|
+
# @option options [id] :block_id
|
|
10
|
+
# Block or page id to fetch comments for.
|
|
11
|
+
#
|
|
12
|
+
# @option options [start_cursor] :start_cursor
|
|
13
|
+
# If supplied, this endpoint will return a page
|
|
14
|
+
# of results starting after the cursor provided.
|
|
15
|
+
# If not supplied, this endpoint will return the
|
|
16
|
+
# first page of results.
|
|
17
|
+
#
|
|
18
|
+
# @option options [page_size] :page_size
|
|
19
|
+
# The number of items from the full list desired in the response.
|
|
20
|
+
# Maximum: 100
|
|
21
|
+
#
|
|
22
|
+
def retrieve_comments(options = {})
|
|
23
|
+
throw ArgumentError.new('Required arguments :block_id missing') if options[:block_id].nil?
|
|
24
|
+
if block_given?
|
|
25
|
+
Pagination::Cursor.new(self, :retrieve_comments, options).each do |page|
|
|
26
|
+
yield page
|
|
27
|
+
end
|
|
28
|
+
else
|
|
29
|
+
get('comments', options)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
#
|
|
34
|
+
# Creates a comment in a page or existing discussion thread.
|
|
35
|
+
# There are two locations you can add a new comment to:
|
|
36
|
+
# - A page
|
|
37
|
+
# - An existing discussion thread
|
|
38
|
+
# If the intention is to add a new comment to a page, a parent object
|
|
39
|
+
# must be provided in the body params. Alternatively, if a new comment
|
|
40
|
+
# is being added to an existing discussion thread, the discussion_id string
|
|
41
|
+
# must be provided in the body params. Exactly one of these parameters must be provided.
|
|
42
|
+
#
|
|
43
|
+
# @option options [Object] :parent
|
|
44
|
+
# A page parent. Either this or a discussion_id is required (not both).
|
|
45
|
+
#
|
|
46
|
+
# @option options [UUID] :discussion_id
|
|
47
|
+
# A UUID identifier for a discussion thread. Either this or a parent object is required (not both).
|
|
48
|
+
#
|
|
49
|
+
# @option options [Object] :rich_text
|
|
50
|
+
# A rich text object.
|
|
51
|
+
def create_comment(options = {})
|
|
52
|
+
if options.dig(:parent, :page_id).nil? && options[:discussion_id].nil?
|
|
53
|
+
throw ArgumentError.new('Required argument :page_id or :discussion_id missing')
|
|
54
|
+
end
|
|
55
|
+
throw ArgumentError.new('Required argument :rich_text missing') if options[:rich_text].nil?
|
|
56
|
+
post('comments', options)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
@@ -40,7 +40,8 @@ module Notion
|
|
|
40
40
|
yield page
|
|
41
41
|
end
|
|
42
42
|
else
|
|
43
|
-
|
|
43
|
+
database_id = options.delete(:database_id)
|
|
44
|
+
post("databases/#{database_id}/query", options)
|
|
44
45
|
end
|
|
45
46
|
end
|
|
46
47
|
|
|
@@ -84,8 +85,9 @@ module Notion
|
|
|
84
85
|
# the name of the database property and the value is a property schema object.
|
|
85
86
|
#
|
|
86
87
|
def update_database(options = {})
|
|
87
|
-
|
|
88
|
-
|
|
88
|
+
database_id = options.delete(:database_id)
|
|
89
|
+
throw ArgumentError.new('Required arguments :database_id missing') if database_id.nil?
|
|
90
|
+
patch("databases/#{database_id}", options)
|
|
89
91
|
end
|
|
90
92
|
|
|
91
93
|
#
|
|
@@ -60,8 +60,9 @@ 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
|
-
|
|
64
|
-
|
|
63
|
+
page_id = options.delete(:page_id)
|
|
64
|
+
throw ArgumentError.new('Required argument :page_id missing') if page_id.nil?
|
|
65
|
+
patch("pages/#{page_id}", options)
|
|
65
66
|
end
|
|
66
67
|
|
|
67
68
|
#
|
data/lib/notion/api/endpoints.rb
CHANGED
|
@@ -5,6 +5,7 @@ require_relative 'endpoints/databases'
|
|
|
5
5
|
require_relative 'endpoints/pages'
|
|
6
6
|
require_relative 'endpoints/users'
|
|
7
7
|
require_relative 'endpoints/search'
|
|
8
|
+
require_relative 'endpoints/comments'
|
|
8
9
|
|
|
9
10
|
module Notion
|
|
10
11
|
module Api
|
|
@@ -14,6 +15,7 @@ module Notion
|
|
|
14
15
|
include Pages
|
|
15
16
|
include Users
|
|
16
17
|
include Search
|
|
18
|
+
include Comments
|
|
17
19
|
end
|
|
18
20
|
end
|
|
19
21
|
end
|
data/lib/notion/config.rb
CHANGED
|
@@ -24,8 +24,8 @@ module Notion
|
|
|
24
24
|
def reset
|
|
25
25
|
self.endpoint = 'https://api.notion.com/v1'
|
|
26
26
|
self.user_agent = "Notion Ruby Client/#{Notion::VERSION}"
|
|
27
|
-
self.ca_path =
|
|
28
|
-
self.ca_file =
|
|
27
|
+
self.ca_path = nil
|
|
28
|
+
self.ca_file = nil
|
|
29
29
|
self.token = nil
|
|
30
30
|
self.proxy = nil
|
|
31
31
|
self.logger = nil
|
|
@@ -21,11 +21,11 @@ module Notion
|
|
|
21
21
|
options[:request] = request_options if request_options.any?
|
|
22
22
|
|
|
23
23
|
::Faraday::Connection.new(endpoint, options) do |connection|
|
|
24
|
-
connection.use ::Faraday::
|
|
24
|
+
connection.use ::Faraday::Multipart::Middleware
|
|
25
25
|
connection.use ::Faraday::Request::UrlEncoded
|
|
26
26
|
connection.use ::Notion::Faraday::Response::RaiseError
|
|
27
|
-
connection.use ::
|
|
28
|
-
connection.use ::
|
|
27
|
+
connection.use ::Faraday::Mashify::Middleware, mash_class: Notion::Messages::Message
|
|
28
|
+
connection.use ::Faraday::Response::Json
|
|
29
29
|
connection.use ::Notion::Faraday::Response::WrapError
|
|
30
30
|
connection.response :logger, logger if logger
|
|
31
31
|
connection.adapter adapter
|
|
@@ -34,4 +34,4 @@ module Notion
|
|
|
34
34
|
end
|
|
35
35
|
end
|
|
36
36
|
end
|
|
37
|
-
end
|
|
37
|
+
end
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
module Notion
|
|
3
3
|
module Faraday
|
|
4
4
|
module Response
|
|
5
|
-
class RaiseError < ::Faraday::Response::
|
|
5
|
+
class RaiseError < ::Faraday::Response::Json
|
|
6
6
|
def on_complete(env)
|
|
7
7
|
raise Notion::Api::Errors::TooManyRequests, env.response if env.status == 429
|
|
8
8
|
|
|
@@ -28,4 +28,4 @@ module Notion
|
|
|
28
28
|
end
|
|
29
29
|
end
|
|
30
30
|
end
|
|
31
|
-
end
|
|
31
|
+
end
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
module Notion
|
|
3
3
|
module Faraday
|
|
4
4
|
module Response
|
|
5
|
-
class WrapError < ::Faraday::Response::
|
|
5
|
+
class WrapError < ::Faraday::Response::Json
|
|
6
6
|
UNAVAILABLE_ERROR_STATUSES = (500..599).freeze
|
|
7
7
|
|
|
8
8
|
def on_complete(env)
|
|
@@ -19,4 +19,4 @@ module Notion
|
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
21
|
end
|
|
22
|
-
end
|
|
22
|
+
end
|
data/lib/notion/version.rb
CHANGED
data/lib/notion-ruby-client.rb
CHANGED
data/notion-ruby-client.gemspec
CHANGED
|
@@ -15,10 +15,10 @@ 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', '>= 6'
|
|
19
18
|
s.add_dependency 'dotenv'
|
|
20
|
-
s.add_dependency 'faraday', '>=
|
|
21
|
-
s.add_dependency '
|
|
19
|
+
s.add_dependency 'faraday', '>= 2.0'
|
|
20
|
+
s.add_dependency 'faraday-mashify', '>= 0.1.1'
|
|
21
|
+
s.add_dependency 'faraday-multipart', '>= 1.0.4'
|
|
22
22
|
s.add_dependency 'hashie', '~> 5'
|
|
23
23
|
s.add_development_dependency 'rake', '~> 13'
|
|
24
24
|
s.add_development_dependency 'rspec'
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: post
|
|
5
|
+
uri: https://api.notion.com/v1/comments
|
|
6
|
+
body:
|
|
7
|
+
encoding: UTF-8
|
|
8
|
+
string: '{"rich_text":[{"text":{"content":"test comment"}}],"discussion_id":"ea116af4839c410bb4ac242a18dc4392"}'
|
|
9
|
+
headers:
|
|
10
|
+
Accept:
|
|
11
|
+
- application/json; charset=utf-8
|
|
12
|
+
User-Agent:
|
|
13
|
+
- Notion Ruby Client/1.0.0
|
|
14
|
+
Authorization:
|
|
15
|
+
- Bearer <NOTION_API_TOKEN>
|
|
16
|
+
Notion-Version:
|
|
17
|
+
- '2022-02-22'
|
|
18
|
+
Content-Type:
|
|
19
|
+
- application/json
|
|
20
|
+
Accept-Encoding:
|
|
21
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
22
|
+
response:
|
|
23
|
+
status:
|
|
24
|
+
code: 200
|
|
25
|
+
message: OK
|
|
26
|
+
headers:
|
|
27
|
+
Date:
|
|
28
|
+
- Fri, 02 Sep 2022 16:29:26 GMT
|
|
29
|
+
Content-Type:
|
|
30
|
+
- application/json; charset=utf-8
|
|
31
|
+
Transfer-Encoding:
|
|
32
|
+
- chunked
|
|
33
|
+
Connection:
|
|
34
|
+
- keep-alive
|
|
35
|
+
Set-Cookie:
|
|
36
|
+
- notion_browser_id=060fba74-6b6c-4d17-bd99-ac0aaa23aefd; Domain=www.notion.so;
|
|
37
|
+
Path=/; Expires=Sat, 02 Sep 2023 16:29:26 GMT; Secure
|
|
38
|
+
- notion_check_cookie_consent=false; Domain=www.notion.so; Path=/; Expires=Sat,
|
|
39
|
+
03 Sep 2022 16:29:26 GMT; Secure
|
|
40
|
+
Content-Security-Policy:
|
|
41
|
+
- "script-src 'self' 'unsafe-inline' 'unsafe-eval' https://gist.github.com https://apis.google.com
|
|
42
|
+
https://www.google.com https://www.gstatic.com https://cdn.amplitude.com https://api.amplitude.com
|
|
43
|
+
https://hkfxbbdzib.notion.so https://widget.intercom.io https://js.intercomcdn.com
|
|
44
|
+
https://static.zdassets.com https://api.smooch.io\t https://logs-01.loggly.com
|
|
45
|
+
https://http-inputs-notion.splunkcloud.com https://cdn.segment.com https://analytics.pgncs.notion.so
|
|
46
|
+
https://o324374.ingest.sentry.io https://checkout.stripe.com https://js.stripe.com
|
|
47
|
+
https://embed.typeform.com https://admin.typeform.com https://public.profitwell.com
|
|
48
|
+
js.sentry-cdn.com https://js.chilipiper.com https://platform.twitter.com https://cdn.syndication.twimg.com
|
|
49
|
+
https://accounts.google.com www.googletagmanager.com https://www.googleadservices.com
|
|
50
|
+
https://googleads.g.doubleclick.net https://api-v2.mutinyhq.io https://client-registry.mutinycdn.com
|
|
51
|
+
https://client.mutinycdn.com https://user-data.mutinycdn.com;connect-src 'self'
|
|
52
|
+
https://msgstore.www.notion.so wss://msgstore.www.notion.so ws://localhost:*
|
|
53
|
+
ws://127.0.0.1:* https://notion-emojis.s3-us-west-2.amazonaws.com https://s3-us-west-2.amazonaws.com
|
|
54
|
+
https://s3.us-west-2.amazonaws.com https://notion-production-snapshots-2.s3.us-west-2.amazonaws.com
|
|
55
|
+
https://cdn.amplitude.com https://api.amplitude.com https://hkfxbbdzib.notion.so
|
|
56
|
+
https://www.notion.so https://api.embed.ly https://js.intercomcdn.com https://api-iam.intercom.io
|
|
57
|
+
https://uploads.intercomcdn.com wss://nexus-websocket-a.intercom.io https://ekr.zdassets.com
|
|
58
|
+
https://ekr.zendesk.com\t https://makenotion.zendesk.com\t https://api.smooch.io\t
|
|
59
|
+
wss://api.smooch.io\t https://logs-01.loggly.com https://http-inputs-notion.splunkcloud.com
|
|
60
|
+
https://cdn.segment.com https://api.segment.io https://analytics.pgncs.notion.so
|
|
61
|
+
https://api.pgncs.notion.so https://o324374.ingest.sentry.io https://checkout.stripe.com
|
|
62
|
+
https://js.stripe.com https://cdn.contentful.com https://preview.contentful.com
|
|
63
|
+
https://images.ctfassets.net https://www2.profitwell.com https://tracking.chilipiper.com
|
|
64
|
+
https://api.chilipiper.com https://api.unsplash.com https://boards-api.greenhouse.io
|
|
65
|
+
https://accounts.google.com https://oauth2.googleapis.com https://www.googleadservices.com
|
|
66
|
+
https://googleads.g.doubleclick.net https://region1.google-analytics.com https://region1.analytics.google.com
|
|
67
|
+
https://www.google-analytics.com https://api-v2.mutinyhq.io https://client-registry.mutinycdn.com
|
|
68
|
+
https://client.mutinycdn.com https://user-data.mutinycdn.com https://api.statuspage.io
|
|
69
|
+
https://pgncd.notion.so https://api.statsig.com https://statsigapi.net https://exp.notion.so
|
|
70
|
+
https://file.notion.so;font-src 'self' data: https://cdnjs.cloudflare.com
|
|
71
|
+
https://js.intercomcdn.com;img-src 'self' data: blob: https: https://platform.twitter.com
|
|
72
|
+
https://syndication.twitter.com https://pbs.twimg.com https://ton.twimg.com
|
|
73
|
+
https://region1.google-analytics.com https://region1.analytics.google.com;style-src
|
|
74
|
+
'self' 'unsafe-inline' https://cdnjs.cloudflare.com https://github.githubassets.com
|
|
75
|
+
https://js.chilipiper.com https://platform.twitter.com https://ton.twimg.com
|
|
76
|
+
https://accounts.google.com;frame-src https: http: https://accounts.google.com;media-src
|
|
77
|
+
https: http: https://file.notion.so"
|
|
78
|
+
X-Dns-Prefetch-Control:
|
|
79
|
+
- 'off'
|
|
80
|
+
X-Frame-Options:
|
|
81
|
+
- SAMEORIGIN
|
|
82
|
+
Strict-Transport-Security:
|
|
83
|
+
- max-age=5184000; includeSubDomains
|
|
84
|
+
X-Download-Options:
|
|
85
|
+
- noopen
|
|
86
|
+
X-Content-Type-Options:
|
|
87
|
+
- nosniff
|
|
88
|
+
X-Permitted-Cross-Domain-Policies:
|
|
89
|
+
- none
|
|
90
|
+
Referrer-Policy:
|
|
91
|
+
- strict-origin-when-cross-origin
|
|
92
|
+
X-Xss-Protection:
|
|
93
|
+
- '0'
|
|
94
|
+
Etag:
|
|
95
|
+
- W/"250-4FWWLrU/GwY9p/XT7GcTdthccMw"
|
|
96
|
+
Vary:
|
|
97
|
+
- Accept-Encoding
|
|
98
|
+
Cf-Cache-Status:
|
|
99
|
+
- DYNAMIC
|
|
100
|
+
Server:
|
|
101
|
+
- cloudflare
|
|
102
|
+
Cf-Ray:
|
|
103
|
+
- 74479fdd5a4e2940-ORD
|
|
104
|
+
body:
|
|
105
|
+
encoding: UTF-8
|
|
106
|
+
string: '{"object":"comment","id":"9e908609-bfcd-42d2-8f54-61c39d82351d","parent":{"type":"block_id","block_id":"1a2f70ab-2615-4dc7-a838-536a3f430af4"},"discussion_id":"ea116af4-839c-410b-b4ac-242a18dc4392","created_time":"2022-09-02T16:29:00.000Z","last_edited_time":"2022-09-02T16:29:00.000Z","created_by":{"object":"user","id":"3eb712e5-c1d7-43f2-ae18-c4d36f846aa1"},"rich_text":[{"type":"text","text":{"content":"test
|
|
107
|
+
comment","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"test
|
|
108
|
+
comment","href":null}]}'
|
|
109
|
+
recorded_at: Fri, 02 Sep 2022 16:29:26 GMT
|
|
110
|
+
recorded_with: VCR 6.0.0
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: post
|
|
5
|
+
uri: https://api.notion.com/v1/comments
|
|
6
|
+
body:
|
|
7
|
+
encoding: UTF-8
|
|
8
|
+
string: '{"rich_text":[{"text":{"content":"test comment"}}],"parent":{"page_id":"3e4bc91d36c74de595113b31c6fdb82c"}}'
|
|
9
|
+
headers:
|
|
10
|
+
Accept:
|
|
11
|
+
- application/json; charset=utf-8
|
|
12
|
+
User-Agent:
|
|
13
|
+
- Notion Ruby Client/1.0.0
|
|
14
|
+
Authorization:
|
|
15
|
+
- Bearer <NOTION_API_TOKEN>
|
|
16
|
+
Notion-Version:
|
|
17
|
+
- '2022-02-22'
|
|
18
|
+
Content-Type:
|
|
19
|
+
- application/json
|
|
20
|
+
Accept-Encoding:
|
|
21
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
22
|
+
response:
|
|
23
|
+
status:
|
|
24
|
+
code: 200
|
|
25
|
+
message: OK
|
|
26
|
+
headers:
|
|
27
|
+
Date:
|
|
28
|
+
- Fri, 02 Sep 2022 16:26:31 GMT
|
|
29
|
+
Content-Type:
|
|
30
|
+
- application/json; charset=utf-8
|
|
31
|
+
Transfer-Encoding:
|
|
32
|
+
- chunked
|
|
33
|
+
Connection:
|
|
34
|
+
- keep-alive
|
|
35
|
+
Set-Cookie:
|
|
36
|
+
- notion_browser_id=fd495a20-5f77-4a87-a210-adb2144bd55b; Domain=www.notion.so;
|
|
37
|
+
Path=/; Expires=Sat, 02 Sep 2023 16:26:31 GMT; Secure
|
|
38
|
+
- notion_check_cookie_consent=false; Domain=www.notion.so; Path=/; Expires=Sat,
|
|
39
|
+
03 Sep 2022 16:26:31 GMT; Secure
|
|
40
|
+
Content-Security-Policy:
|
|
41
|
+
- "script-src 'self' 'unsafe-inline' 'unsafe-eval' https://gist.github.com https://apis.google.com
|
|
42
|
+
https://www.google.com https://www.gstatic.com https://cdn.amplitude.com https://api.amplitude.com
|
|
43
|
+
https://hkfxbbdzib.notion.so https://widget.intercom.io https://js.intercomcdn.com
|
|
44
|
+
https://static.zdassets.com https://api.smooch.io\t https://logs-01.loggly.com
|
|
45
|
+
https://http-inputs-notion.splunkcloud.com https://cdn.segment.com https://analytics.pgncs.notion.so
|
|
46
|
+
https://o324374.ingest.sentry.io https://checkout.stripe.com https://js.stripe.com
|
|
47
|
+
https://embed.typeform.com https://admin.typeform.com https://public.profitwell.com
|
|
48
|
+
js.sentry-cdn.com https://js.chilipiper.com https://platform.twitter.com https://cdn.syndication.twimg.com
|
|
49
|
+
https://accounts.google.com www.googletagmanager.com https://www.googleadservices.com
|
|
50
|
+
https://googleads.g.doubleclick.net https://api-v2.mutinyhq.io https://client-registry.mutinycdn.com
|
|
51
|
+
https://client.mutinycdn.com https://user-data.mutinycdn.com;connect-src 'self'
|
|
52
|
+
https://msgstore.www.notion.so wss://msgstore.www.notion.so ws://localhost:*
|
|
53
|
+
ws://127.0.0.1:* https://notion-emojis.s3-us-west-2.amazonaws.com https://s3-us-west-2.amazonaws.com
|
|
54
|
+
https://s3.us-west-2.amazonaws.com https://notion-production-snapshots-2.s3.us-west-2.amazonaws.com
|
|
55
|
+
https://cdn.amplitude.com https://api.amplitude.com https://hkfxbbdzib.notion.so
|
|
56
|
+
https://www.notion.so https://api.embed.ly https://js.intercomcdn.com https://api-iam.intercom.io
|
|
57
|
+
https://uploads.intercomcdn.com wss://nexus-websocket-a.intercom.io https://ekr.zdassets.com
|
|
58
|
+
https://ekr.zendesk.com\t https://makenotion.zendesk.com\t https://api.smooch.io\t
|
|
59
|
+
wss://api.smooch.io\t https://logs-01.loggly.com https://http-inputs-notion.splunkcloud.com
|
|
60
|
+
https://cdn.segment.com https://api.segment.io https://analytics.pgncs.notion.so
|
|
61
|
+
https://api.pgncs.notion.so https://o324374.ingest.sentry.io https://checkout.stripe.com
|
|
62
|
+
https://js.stripe.com https://cdn.contentful.com https://preview.contentful.com
|
|
63
|
+
https://images.ctfassets.net https://www2.profitwell.com https://tracking.chilipiper.com
|
|
64
|
+
https://api.chilipiper.com https://api.unsplash.com https://boards-api.greenhouse.io
|
|
65
|
+
https://accounts.google.com https://oauth2.googleapis.com https://www.googleadservices.com
|
|
66
|
+
https://googleads.g.doubleclick.net https://region1.google-analytics.com https://region1.analytics.google.com
|
|
67
|
+
https://www.google-analytics.com https://api-v2.mutinyhq.io https://client-registry.mutinycdn.com
|
|
68
|
+
https://client.mutinycdn.com https://user-data.mutinycdn.com https://api.statuspage.io
|
|
69
|
+
https://pgncd.notion.so https://api.statsig.com https://statsigapi.net https://exp.notion.so
|
|
70
|
+
https://file.notion.so;font-src 'self' data: https://cdnjs.cloudflare.com
|
|
71
|
+
https://js.intercomcdn.com;img-src 'self' data: blob: https: https://platform.twitter.com
|
|
72
|
+
https://syndication.twitter.com https://pbs.twimg.com https://ton.twimg.com
|
|
73
|
+
https://region1.google-analytics.com https://region1.analytics.google.com;style-src
|
|
74
|
+
'self' 'unsafe-inline' https://cdnjs.cloudflare.com https://github.githubassets.com
|
|
75
|
+
https://js.chilipiper.com https://platform.twitter.com https://ton.twimg.com
|
|
76
|
+
https://accounts.google.com;frame-src https: http: https://accounts.google.com;media-src
|
|
77
|
+
https: http: https://file.notion.so"
|
|
78
|
+
X-Dns-Prefetch-Control:
|
|
79
|
+
- 'off'
|
|
80
|
+
X-Frame-Options:
|
|
81
|
+
- SAMEORIGIN
|
|
82
|
+
Strict-Transport-Security:
|
|
83
|
+
- max-age=5184000; includeSubDomains
|
|
84
|
+
X-Download-Options:
|
|
85
|
+
- noopen
|
|
86
|
+
X-Content-Type-Options:
|
|
87
|
+
- nosniff
|
|
88
|
+
X-Permitted-Cross-Domain-Policies:
|
|
89
|
+
- none
|
|
90
|
+
Referrer-Policy:
|
|
91
|
+
- strict-origin-when-cross-origin
|
|
92
|
+
X-Xss-Protection:
|
|
93
|
+
- '0'
|
|
94
|
+
Etag:
|
|
95
|
+
- W/"24e-lwOvl3pLRgq3uaVwDU7YNYGeauA"
|
|
96
|
+
Vary:
|
|
97
|
+
- Accept-Encoding
|
|
98
|
+
Cf-Cache-Status:
|
|
99
|
+
- DYNAMIC
|
|
100
|
+
Server:
|
|
101
|
+
- cloudflare
|
|
102
|
+
Cf-Ray:
|
|
103
|
+
- 74479b9bdc202d94-ORD
|
|
104
|
+
body:
|
|
105
|
+
encoding: UTF-8
|
|
106
|
+
string: '{"object":"comment","id":"95ef4675-e3c0-428c-b937-ac8d6805ac04","parent":{"type":"page_id","page_id":"3e4bc91d-36c7-4de5-9511-3b31c6fdb82c"},"discussion_id":"4cbe01af-8163-4b03-957d-cac2691b9839","created_time":"2022-09-02T16:26:00.000Z","last_edited_time":"2022-09-02T16:26:00.000Z","created_by":{"object":"user","id":"3eb712e5-c1d7-43f2-ae18-c4d36f846aa1"},"rich_text":[{"type":"text","text":{"content":"test
|
|
107
|
+
comment","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"test
|
|
108
|
+
comment","href":null}]}'
|
|
109
|
+
recorded_at: Fri, 02 Sep 2022 16:26:31 GMT
|
|
110
|
+
recorded_with: VCR 6.0.0
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: get
|
|
5
|
+
uri: https://api.notion.com/v1/comments?block_id=1a2f70ab26154dc7a838536a3f430af4
|
|
6
|
+
body:
|
|
7
|
+
encoding: US-ASCII
|
|
8
|
+
string: ''
|
|
9
|
+
headers:
|
|
10
|
+
Accept:
|
|
11
|
+
- application/json; charset=utf-8
|
|
12
|
+
User-Agent:
|
|
13
|
+
- Notion Ruby Client/1.0.0
|
|
14
|
+
Authorization:
|
|
15
|
+
- Bearer <NOTION_API_TOKEN>
|
|
16
|
+
Notion-Version:
|
|
17
|
+
- '2022-02-22'
|
|
18
|
+
Accept-Encoding:
|
|
19
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
20
|
+
response:
|
|
21
|
+
status:
|
|
22
|
+
code: 200
|
|
23
|
+
message: OK
|
|
24
|
+
headers:
|
|
25
|
+
Date:
|
|
26
|
+
- Fri, 02 Sep 2022 16:21:51 GMT
|
|
27
|
+
Content-Type:
|
|
28
|
+
- application/json; charset=utf-8
|
|
29
|
+
Transfer-Encoding:
|
|
30
|
+
- chunked
|
|
31
|
+
Connection:
|
|
32
|
+
- keep-alive
|
|
33
|
+
Set-Cookie:
|
|
34
|
+
- notion_browser_id=86d25b85-2df9-4e71-abd7-1d3e0b02bc8a; Domain=www.notion.so;
|
|
35
|
+
Path=/; Expires=Sat, 02 Sep 2023 16:21:51 GMT; Secure
|
|
36
|
+
- notion_check_cookie_consent=false; Domain=www.notion.so; Path=/; Expires=Sat,
|
|
37
|
+
03 Sep 2022 16:21:51 GMT; Secure
|
|
38
|
+
Content-Security-Policy:
|
|
39
|
+
- "script-src 'self' 'unsafe-inline' 'unsafe-eval' https://gist.github.com https://apis.google.com
|
|
40
|
+
https://www.google.com https://www.gstatic.com https://cdn.amplitude.com https://api.amplitude.com
|
|
41
|
+
https://hkfxbbdzib.notion.so https://widget.intercom.io https://js.intercomcdn.com
|
|
42
|
+
https://static.zdassets.com https://api.smooch.io\t https://logs-01.loggly.com
|
|
43
|
+
https://http-inputs-notion.splunkcloud.com https://cdn.segment.com https://analytics.pgncs.notion.so
|
|
44
|
+
https://o324374.ingest.sentry.io https://checkout.stripe.com https://js.stripe.com
|
|
45
|
+
https://embed.typeform.com https://admin.typeform.com https://public.profitwell.com
|
|
46
|
+
js.sentry-cdn.com https://js.chilipiper.com https://platform.twitter.com https://cdn.syndication.twimg.com
|
|
47
|
+
https://accounts.google.com www.googletagmanager.com https://www.googleadservices.com
|
|
48
|
+
https://googleads.g.doubleclick.net https://api-v2.mutinyhq.io https://client-registry.mutinycdn.com
|
|
49
|
+
https://client.mutinycdn.com https://user-data.mutinycdn.com;connect-src 'self'
|
|
50
|
+
https://msgstore.www.notion.so wss://msgstore.www.notion.so ws://localhost:*
|
|
51
|
+
ws://127.0.0.1:* https://notion-emojis.s3-us-west-2.amazonaws.com https://s3-us-west-2.amazonaws.com
|
|
52
|
+
https://s3.us-west-2.amazonaws.com https://notion-production-snapshots-2.s3.us-west-2.amazonaws.com
|
|
53
|
+
https://cdn.amplitude.com https://api.amplitude.com https://hkfxbbdzib.notion.so
|
|
54
|
+
https://www.notion.so https://api.embed.ly https://js.intercomcdn.com https://api-iam.intercom.io
|
|
55
|
+
https://uploads.intercomcdn.com wss://nexus-websocket-a.intercom.io https://ekr.zdassets.com
|
|
56
|
+
https://ekr.zendesk.com\t https://makenotion.zendesk.com\t https://api.smooch.io\t
|
|
57
|
+
wss://api.smooch.io\t https://logs-01.loggly.com https://http-inputs-notion.splunkcloud.com
|
|
58
|
+
https://cdn.segment.com https://api.segment.io https://analytics.pgncs.notion.so
|
|
59
|
+
https://api.pgncs.notion.so https://o324374.ingest.sentry.io https://checkout.stripe.com
|
|
60
|
+
https://js.stripe.com https://cdn.contentful.com https://preview.contentful.com
|
|
61
|
+
https://images.ctfassets.net https://www2.profitwell.com https://tracking.chilipiper.com
|
|
62
|
+
https://api.chilipiper.com https://api.unsplash.com https://boards-api.greenhouse.io
|
|
63
|
+
https://accounts.google.com https://oauth2.googleapis.com https://www.googleadservices.com
|
|
64
|
+
https://googleads.g.doubleclick.net https://region1.google-analytics.com https://region1.analytics.google.com
|
|
65
|
+
https://www.google-analytics.com https://api-v2.mutinyhq.io https://client-registry.mutinycdn.com
|
|
66
|
+
https://client.mutinycdn.com https://user-data.mutinycdn.com https://api.statuspage.io
|
|
67
|
+
https://pgncd.notion.so https://api.statsig.com https://statsigapi.net https://exp.notion.so
|
|
68
|
+
https://file.notion.so;font-src 'self' data: https://cdnjs.cloudflare.com
|
|
69
|
+
https://js.intercomcdn.com;img-src 'self' data: blob: https: https://platform.twitter.com
|
|
70
|
+
https://syndication.twitter.com https://pbs.twimg.com https://ton.twimg.com
|
|
71
|
+
https://region1.google-analytics.com https://region1.analytics.google.com;style-src
|
|
72
|
+
'self' 'unsafe-inline' https://cdnjs.cloudflare.com https://github.githubassets.com
|
|
73
|
+
https://js.chilipiper.com https://platform.twitter.com https://ton.twimg.com
|
|
74
|
+
https://accounts.google.com;frame-src https: http: https://accounts.google.com;media-src
|
|
75
|
+
https: http: https://file.notion.so"
|
|
76
|
+
X-Dns-Prefetch-Control:
|
|
77
|
+
- 'off'
|
|
78
|
+
X-Frame-Options:
|
|
79
|
+
- SAMEORIGIN
|
|
80
|
+
Strict-Transport-Security:
|
|
81
|
+
- max-age=5184000; includeSubDomains
|
|
82
|
+
X-Download-Options:
|
|
83
|
+
- noopen
|
|
84
|
+
X-Content-Type-Options:
|
|
85
|
+
- nosniff
|
|
86
|
+
X-Permitted-Cross-Domain-Policies:
|
|
87
|
+
- none
|
|
88
|
+
Referrer-Policy:
|
|
89
|
+
- strict-origin-when-cross-origin
|
|
90
|
+
X-Xss-Protection:
|
|
91
|
+
- '0'
|
|
92
|
+
Etag:
|
|
93
|
+
- W/"2a4-a2pWQq0rrllNzewHfiDfmBJ/vB8"
|
|
94
|
+
Vary:
|
|
95
|
+
- Accept-Encoding
|
|
96
|
+
Cf-Cache-Status:
|
|
97
|
+
- DYNAMIC
|
|
98
|
+
Server:
|
|
99
|
+
- cloudflare
|
|
100
|
+
Cf-Ray:
|
|
101
|
+
- 744794c32dac2c80-ORD
|
|
102
|
+
body:
|
|
103
|
+
encoding: UTF-8
|
|
104
|
+
string: '{"object":"list","results":[{"object":"comment","id":"8539f829-54f8-4389-a4a3-a6bc3d40636a","parent":{"type":"block_id","block_id":"1a2f70ab-2615-4dc7-a838-536a3f430af4"},"discussion_id":"ea116af4-839c-410b-b4ac-242a18dc4392","created_time":"2022-09-02T16:19:00.000Z","last_edited_time":"2022-09-02T16:19:00.000Z","created_by":{"object":"user","id":"240574f5-3adc-498c-a504-7733b0ea337b"},"rich_text":[{"type":"text","text":{"content":"hello!","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"hello!","href":null}]}],"next_cursor":null,"has_more":false,"type":"comment","comment":{}}'
|
|
105
|
+
recorded_at: Fri, 02 Sep 2022 16:21:51 GMT
|
|
106
|
+
recorded_with: VCR 6.0.0
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
|
|
4
|
+
RSpec.describe Notion::Api::Endpoints::Comments do
|
|
5
|
+
let(:client) { Notion::Client.new }
|
|
6
|
+
let(:discussion_comment) do
|
|
7
|
+
{
|
|
8
|
+
discussion_id: 'ea116af4839c410bb4ac242a18dc4392',
|
|
9
|
+
rich_text: [
|
|
10
|
+
{
|
|
11
|
+
text: {
|
|
12
|
+
content: 'test comment'
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
]
|
|
16
|
+
}
|
|
17
|
+
end
|
|
18
|
+
let(:page_comment) do
|
|
19
|
+
{
|
|
20
|
+
parent: { page_id: '3e4bc91d36c74de595113b31c6fdb82c' },
|
|
21
|
+
rich_text: [
|
|
22
|
+
{
|
|
23
|
+
text: {
|
|
24
|
+
content: 'test comment'
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
describe '#retrieve_comments' do
|
|
32
|
+
it 'retrieves comments', vcr: { cassette_name: 'retrieve_comments' } do
|
|
33
|
+
response = client.retrieve_comments(block_id: '1a2f70ab26154dc7a838536a3f430af4')
|
|
34
|
+
expect(response.results.size).to eq 1
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
describe '#create_comment' do
|
|
39
|
+
it 'creates a comment on a page', vcr: { cassette_name: 'create_page_comment' } do
|
|
40
|
+
response = client.create_comment(page_comment)
|
|
41
|
+
expect(response.created_time).not_to be_empty
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it 'creates a comment on a discussion', vcr: { cassette_name: 'create_discussion_comment' } do
|
|
45
|
+
response = client.create_comment(discussion_comment)
|
|
46
|
+
expect(response.created_time).not_to be_empty
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
metadata
CHANGED
|
@@ -1,71 +1,71 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: notion-ruby-client
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nicolas Goutay
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2023-02-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
|
-
name:
|
|
14
|
+
name: dotenv
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
17
|
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '
|
|
19
|
+
version: '0'
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - ">="
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '
|
|
26
|
+
version: '0'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
|
-
name:
|
|
28
|
+
name: faraday
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
31
|
- - ">="
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '0'
|
|
33
|
+
version: '2.0'
|
|
34
34
|
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
38
|
- - ">="
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: '0'
|
|
40
|
+
version: '2.0'
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
|
-
name: faraday
|
|
42
|
+
name: faraday-mashify
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
44
44
|
requirements:
|
|
45
45
|
- - ">="
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
|
-
version:
|
|
47
|
+
version: 0.1.1
|
|
48
48
|
type: :runtime
|
|
49
49
|
prerelease: false
|
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
51
|
requirements:
|
|
52
52
|
- - ">="
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
|
-
version:
|
|
54
|
+
version: 0.1.1
|
|
55
55
|
- !ruby/object:Gem::Dependency
|
|
56
|
-
name:
|
|
56
|
+
name: faraday-multipart
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
|
58
58
|
requirements:
|
|
59
59
|
- - ">="
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
|
-
version:
|
|
61
|
+
version: 1.0.4
|
|
62
62
|
type: :runtime
|
|
63
63
|
prerelease: false
|
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
|
66
66
|
- - ">="
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
|
-
version:
|
|
68
|
+
version: 1.0.4
|
|
69
69
|
- !ruby/object:Gem::Dependency
|
|
70
70
|
name: hashie
|
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -202,6 +202,7 @@ files:
|
|
|
202
202
|
- ".devcontainer/boot.sh"
|
|
203
203
|
- ".devcontainer/devcontainer.json"
|
|
204
204
|
- ".github/workflows/ci.yml"
|
|
205
|
+
- ".github/workflows/rubocop.yml"
|
|
205
206
|
- ".gitignore"
|
|
206
207
|
- ".rspec"
|
|
207
208
|
- ".rubocop.yml"
|
|
@@ -219,6 +220,7 @@ files:
|
|
|
219
220
|
- lib/notion.rb
|
|
220
221
|
- lib/notion/api/endpoints.rb
|
|
221
222
|
- lib/notion/api/endpoints/blocks.rb
|
|
223
|
+
- lib/notion/api/endpoints/comments.rb
|
|
222
224
|
- lib/notion/api/endpoints/databases.rb
|
|
223
225
|
- lib/notion/api/endpoints/pages.rb
|
|
224
226
|
- lib/notion/api/endpoints/search.rb
|
|
@@ -244,7 +246,9 @@ files:
|
|
|
244
246
|
- spec/fixtures/notion/block_append_children.yml
|
|
245
247
|
- spec/fixtures/notion/block_children.yml
|
|
246
248
|
- spec/fixtures/notion/create_database.yml
|
|
249
|
+
- spec/fixtures/notion/create_discussion_comment.yml
|
|
247
250
|
- spec/fixtures/notion/create_page.yml
|
|
251
|
+
- spec/fixtures/notion/create_page_comment.yml
|
|
248
252
|
- spec/fixtures/notion/database.yml
|
|
249
253
|
- spec/fixtures/notion/database_query.yml
|
|
250
254
|
- spec/fixtures/notion/delete_block.yml
|
|
@@ -255,6 +259,7 @@ files:
|
|
|
255
259
|
- spec/fixtures/notion/paginated_databases_list.yml
|
|
256
260
|
- spec/fixtures/notion/paginated_search.yml
|
|
257
261
|
- spec/fixtures/notion/paginated_users_list.yml
|
|
262
|
+
- spec/fixtures/notion/retrieve_comments.yml
|
|
258
263
|
- spec/fixtures/notion/search.yml
|
|
259
264
|
- spec/fixtures/notion/search_with_query.yml
|
|
260
265
|
- spec/fixtures/notion/update_block.yml
|
|
@@ -264,6 +269,7 @@ files:
|
|
|
264
269
|
- spec/fixtures/notion/users_list.yml
|
|
265
270
|
- spec/fixtures/notion/users_me.yml
|
|
266
271
|
- spec/notion/api/endpoints/blocks_spec.rb
|
|
272
|
+
- spec/notion/api/endpoints/comments_spec.rb
|
|
267
273
|
- spec/notion/api/endpoints/databases_spec.rb
|
|
268
274
|
- spec/notion/api/endpoints/pages_spec.rb
|
|
269
275
|
- spec/notion/api/endpoints/search_spec.rb
|
|
@@ -302,7 +308,9 @@ test_files:
|
|
|
302
308
|
- spec/fixtures/notion/block_append_children.yml
|
|
303
309
|
- spec/fixtures/notion/block_children.yml
|
|
304
310
|
- spec/fixtures/notion/create_database.yml
|
|
311
|
+
- spec/fixtures/notion/create_discussion_comment.yml
|
|
305
312
|
- spec/fixtures/notion/create_page.yml
|
|
313
|
+
- spec/fixtures/notion/create_page_comment.yml
|
|
306
314
|
- spec/fixtures/notion/database.yml
|
|
307
315
|
- spec/fixtures/notion/database_query.yml
|
|
308
316
|
- spec/fixtures/notion/delete_block.yml
|
|
@@ -313,6 +321,7 @@ test_files:
|
|
|
313
321
|
- spec/fixtures/notion/paginated_databases_list.yml
|
|
314
322
|
- spec/fixtures/notion/paginated_search.yml
|
|
315
323
|
- spec/fixtures/notion/paginated_users_list.yml
|
|
324
|
+
- spec/fixtures/notion/retrieve_comments.yml
|
|
316
325
|
- spec/fixtures/notion/search.yml
|
|
317
326
|
- spec/fixtures/notion/search_with_query.yml
|
|
318
327
|
- spec/fixtures/notion/update_block.yml
|
|
@@ -322,6 +331,7 @@ test_files:
|
|
|
322
331
|
- spec/fixtures/notion/users_list.yml
|
|
323
332
|
- spec/fixtures/notion/users_me.yml
|
|
324
333
|
- spec/notion/api/endpoints/blocks_spec.rb
|
|
334
|
+
- spec/notion/api/endpoints/comments_spec.rb
|
|
325
335
|
- spec/notion/api/endpoints/databases_spec.rb
|
|
326
336
|
- spec/notion/api/endpoints/pages_spec.rb
|
|
327
337
|
- spec/notion/api/endpoints/search_spec.rb
|