notion-ruby-client 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/Gemfile.lock +1 -1
- data/README.md +41 -0
- data/lib/notion/api/endpoints/comments.rb +61 -0
- data/lib/notion/api/endpoints.rb +2 -0
- data/lib/notion/version.rb +1 -1
- 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 +11 -2
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/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
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
|
+
|
1
9
|
### 1.1.0 (2023-02-23)
|
2
10
|
|
3
11
|
#### Breaking changes
|
data/Gemfile.lock
CHANGED
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)
|
@@ -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
|
@@ -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
|
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/version.rb
CHANGED
@@ -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,14 +1,14 @@
|
|
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: 2023-02-
|
11
|
+
date: 2023-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dotenv
|
@@ -220,6 +220,7 @@ files:
|
|
220
220
|
- lib/notion.rb
|
221
221
|
- lib/notion/api/endpoints.rb
|
222
222
|
- lib/notion/api/endpoints/blocks.rb
|
223
|
+
- lib/notion/api/endpoints/comments.rb
|
223
224
|
- lib/notion/api/endpoints/databases.rb
|
224
225
|
- lib/notion/api/endpoints/pages.rb
|
225
226
|
- lib/notion/api/endpoints/search.rb
|
@@ -245,7 +246,9 @@ files:
|
|
245
246
|
- spec/fixtures/notion/block_append_children.yml
|
246
247
|
- spec/fixtures/notion/block_children.yml
|
247
248
|
- spec/fixtures/notion/create_database.yml
|
249
|
+
- spec/fixtures/notion/create_discussion_comment.yml
|
248
250
|
- spec/fixtures/notion/create_page.yml
|
251
|
+
- spec/fixtures/notion/create_page_comment.yml
|
249
252
|
- spec/fixtures/notion/database.yml
|
250
253
|
- spec/fixtures/notion/database_query.yml
|
251
254
|
- spec/fixtures/notion/delete_block.yml
|
@@ -256,6 +259,7 @@ files:
|
|
256
259
|
- spec/fixtures/notion/paginated_databases_list.yml
|
257
260
|
- spec/fixtures/notion/paginated_search.yml
|
258
261
|
- spec/fixtures/notion/paginated_users_list.yml
|
262
|
+
- spec/fixtures/notion/retrieve_comments.yml
|
259
263
|
- spec/fixtures/notion/search.yml
|
260
264
|
- spec/fixtures/notion/search_with_query.yml
|
261
265
|
- spec/fixtures/notion/update_block.yml
|
@@ -265,6 +269,7 @@ files:
|
|
265
269
|
- spec/fixtures/notion/users_list.yml
|
266
270
|
- spec/fixtures/notion/users_me.yml
|
267
271
|
- spec/notion/api/endpoints/blocks_spec.rb
|
272
|
+
- spec/notion/api/endpoints/comments_spec.rb
|
268
273
|
- spec/notion/api/endpoints/databases_spec.rb
|
269
274
|
- spec/notion/api/endpoints/pages_spec.rb
|
270
275
|
- spec/notion/api/endpoints/search_spec.rb
|
@@ -303,7 +308,9 @@ test_files:
|
|
303
308
|
- spec/fixtures/notion/block_append_children.yml
|
304
309
|
- spec/fixtures/notion/block_children.yml
|
305
310
|
- spec/fixtures/notion/create_database.yml
|
311
|
+
- spec/fixtures/notion/create_discussion_comment.yml
|
306
312
|
- spec/fixtures/notion/create_page.yml
|
313
|
+
- spec/fixtures/notion/create_page_comment.yml
|
307
314
|
- spec/fixtures/notion/database.yml
|
308
315
|
- spec/fixtures/notion/database_query.yml
|
309
316
|
- spec/fixtures/notion/delete_block.yml
|
@@ -314,6 +321,7 @@ test_files:
|
|
314
321
|
- spec/fixtures/notion/paginated_databases_list.yml
|
315
322
|
- spec/fixtures/notion/paginated_search.yml
|
316
323
|
- spec/fixtures/notion/paginated_users_list.yml
|
324
|
+
- spec/fixtures/notion/retrieve_comments.yml
|
317
325
|
- spec/fixtures/notion/search.yml
|
318
326
|
- spec/fixtures/notion/search_with_query.yml
|
319
327
|
- spec/fixtures/notion/update_block.yml
|
@@ -323,6 +331,7 @@ test_files:
|
|
323
331
|
- spec/fixtures/notion/users_list.yml
|
324
332
|
- spec/fixtures/notion/users_me.yml
|
325
333
|
- spec/notion/api/endpoints/blocks_spec.rb
|
334
|
+
- spec/notion/api/endpoints/comments_spec.rb
|
326
335
|
- spec/notion/api/endpoints/databases_spec.rb
|
327
336
|
- spec/notion/api/endpoints/pages_spec.rb
|
328
337
|
- spec/notion/api/endpoints/search_spec.rb
|