notion-ruby-client 1.2.0 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8e4e676c9ca818a9cdcab31f6b085d00860bd74a102f668fdbe60cd209eaa442
4
- data.tar.gz: 57c19debac66cc452d441ce718bdd4f1d410c2884ac1b422d75cfe0fa228b043
3
+ metadata.gz: 6d2a28d2c520d40c63b13b4aec8e26b2bcfb546dad4615ade0622c538e8f2201
4
+ data.tar.gz: a58ce560c3d0c2c3f777a53796362dcdd1a78cb3ecd4483de259b9ec967e10dc
5
5
  SHA512:
6
- metadata.gz: fb1a69701d1b81d3209f9b4d36fb73e204d60fd6239be0b922fa7ea6ebf5ac24ec62bf7949cbfee34867ec5da706d1446ccde8a733d46eefad3fe6dda9cd2929
7
- data.tar.gz: 38dde2575a611e67d4b6222f6c79299aef06869e72963765ba850ad567c1b36b77e5cb521c60c1ba9044537b6a4a7f781e276604e0770c61b69b96726596f97c
6
+ metadata.gz: 8a6664aa8b477755525eff092e5e87e5b0076a8e90630fc5784e3d50366e9f0200bac8ecbc52fc042b0cc1305e36672e2453a6cd05cd400f141f839503612910
7
+ data.tar.gz: c2c4bc140e6fc4cc338f638f6c8b52dca52a1ed8bb963900a661b88f165bd42b692e44389144cfbd1019ba450905dc8a1487627599932eeef6ddc62bece5354c
data/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ ### 1.2.2 (2023-10-02)
2
+
3
+ #### Improved
4
+
5
+ - Remove `dotenv` as a runtime dependency (@sinsoku, #49)
6
+ - Remove the outdated mention of the List Databases enpoint in the README (@soruma, #48)
7
+
8
+ ### 1.2.1 (2023-02-26)
9
+
10
+ #### New
11
+
12
+ - Add support for creating a page as child of another page (thanks @TABeauchat!)
13
+
1
14
  ### 1.2.0 (2023-02-26)
2
15
 
3
16
  #### New
data/Gemfile.lock CHANGED
@@ -1,8 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- notion-ruby-client (1.2.0)
5
- dotenv
4
+ notion-ruby-client (1.2.2)
6
5
  faraday (>= 2.0)
7
6
  faraday-mashify (>= 0.1.1)
8
7
  faraday-multipart (>= 1.0.4)
@@ -79,6 +78,7 @@ PLATFORMS
79
78
  x86_64-linux
80
79
 
81
80
  DEPENDENCIES
81
+ dotenv
82
82
  notion-ruby-client!
83
83
  rake (~> 13)
84
84
  rspec
data/README.md CHANGED
@@ -20,7 +20,6 @@ A Ruby client for the Notion API.
20
20
  - [Create a Database](#create-a-database)
21
21
  - [Update a Database](#update-a-database)
22
22
  - [Retrieve a database](#retrieve-a-database)
23
- - [List databases](#list-databases)
24
23
  - [Pages](#pages)
25
24
  - [Retrieve a page](#retrieve-a-page)
26
25
  - [Create a page](#create-a-page)
@@ -241,24 +240,6 @@ client.database(database_id: 'e383bcee-e0d8-4564-9c63-900d307abdb0')
241
240
 
242
241
  See the full endpoint documentation on [Notion Developers](https://developers.notion.com/reference/retrieve-a-database).
243
242
 
244
- #### List databases
245
-
246
- List all [Databases](https://developers.notion.com/reference-link/database) shared with the authenticated integration.
247
-
248
- ```ruby
249
- client.databases_list # retrieves the first page
250
-
251
- client.databases_list(start_cursor: 'fe2cc560-036c-44cd-90e8-294d5a74cebc')
252
-
253
- client.databases_list do |page|
254
- # paginate through all databases
255
- end
256
- ```
257
-
258
- See [Pagination](#pagination) for details about how to iterate through the list.
259
-
260
- See the full endpoint documentation on [Notion Developers](https://developers.notion.com/reference/list-databases).
261
-
262
243
  ### Pages
263
244
 
264
245
  #### Retrieve a page
@@ -283,6 +264,8 @@ If the parent is a page, the only valid property is `title`.
283
264
 
284
265
  The new page may include page content, described as [blocks](https://developers.notion.com/reference-link/block) in the children parameter.
285
266
 
267
+ The following example creates a new page within the specified database:
268
+
286
269
  ```ruby
287
270
  properties = {
288
271
  'Name': {
@@ -346,6 +329,54 @@ client.create_page(
346
329
  )
347
330
  ```
348
331
 
332
+ This example creates a new page as a child of an existing page.
333
+
334
+ ```ruby
335
+ properties = {
336
+ title: [
337
+ {
338
+ "type": "text",
339
+ "text": {
340
+ "content": "My favorite food",
341
+ "link": null
342
+ }
343
+ }
344
+ ]
345
+ }
346
+ children = [
347
+ {
348
+ 'object': 'block',
349
+ 'type': 'heading_2',
350
+ 'heading_2': {
351
+ 'rich_text': [{
352
+ 'type': 'text',
353
+ 'text': { 'content': 'Lacinato kale' }
354
+ }]
355
+ }
356
+ },
357
+ {
358
+ 'object': 'block',
359
+ 'type': 'paragraph',
360
+ 'paragraph': {
361
+ 'rich_text': [
362
+ {
363
+ 'type': 'text',
364
+ 'text': {
365
+ '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.',
366
+ 'link': { 'url': 'https://en.wikipedia.org/wiki/Lacinato_kale' }
367
+ }
368
+ }
369
+ ]
370
+ }
371
+ }
372
+ ]
373
+ client.create_page(
374
+ parent: { page_id: 'feb1cdfaab6a43cea4ecbc9e8de63ef7'},
375
+ properties: properties,
376
+ children: children
377
+ )
378
+ ```
379
+
349
380
  See the full endpoint documentation on [Notion Developers](https://developers.notion.com/reference/post-page).
350
381
 
351
382
  #### Update page
@@ -38,7 +38,10 @@ module Notion
38
38
  # @option options [Object] :children
39
39
  # An optional array of Block objects representing the Page’s content
40
40
  def create_page(options = {})
41
- throw ArgumentError.new('Required argument :parent.database_id missing') if options.dig(:parent, :database_id).nil?
41
+ if options.dig(:parent, :database_id).nil? && options.dig(:parent, :page_id).nil?
42
+ throw ArgumentError.new('Required argument :parent.database_id or :parent.page_id required')
43
+ end
44
+
42
45
  post("pages", options)
43
46
  end
44
47
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  module Notion
3
- VERSION = '1.2.0'
3
+ VERSION = '1.2.2'
4
4
  NOTION_REQUEST_VERSION = '2022-02-22'
5
5
  end
@@ -15,11 +15,11 @@ 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 'dotenv'
19
18
  s.add_dependency 'faraday', '>= 2.0'
20
19
  s.add_dependency 'faraday-mashify', '>= 0.1.1'
21
20
  s.add_dependency 'faraday-multipart', '>= 1.0.4'
22
21
  s.add_dependency 'hashie', '~> 5'
22
+ s.add_development_dependency 'dotenv'
23
23
  s.add_development_dependency 'rake', '~> 13'
24
24
  s.add_development_dependency 'rspec'
25
25
  s.add_development_dependency 'rubocop', '~> 0.82.0'
@@ -0,0 +1,128 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.notion.com/v1/pages
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"parent":{"page_id":"0593a719ff2e44aaa14a2bf169429284"},"properties":{"title":[{"text":{"content":"Another
9
+ Notion page"}}]},"children":[{"object":"block","type":"heading_2","heading_2":{"rich_text":[{"type":"text","text":{"content":"My
10
+ Heading 2"}}]}}]}'
11
+ headers:
12
+ Accept:
13
+ - application/json; charset=utf-8
14
+ User-Agent:
15
+ - Notion Ruby Client/1.2.0
16
+ Authorization:
17
+ - Bearer <NOTION_API_TOKEN>
18
+ Notion-Version:
19
+ - '2022-02-22'
20
+ Content-Type:
21
+ - application/json
22
+ Accept-Encoding:
23
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
24
+ response:
25
+ status:
26
+ code: 200
27
+ message: OK
28
+ headers:
29
+ Date:
30
+ - Sun, 26 Feb 2023 17:21:54 GMT
31
+ Content-Type:
32
+ - application/json; charset=utf-8
33
+ Transfer-Encoding:
34
+ - chunked
35
+ Connection:
36
+ - keep-alive
37
+ Set-Cookie:
38
+ - __cf_bm=3uGTzmXnS9NSPlzB6MC25WX5a50pZafwabcoIG1k3mg-1677432114-0-AcTcZQhFHvWa2oYDeQ8RwgCXQcgn4zIPacEQnLYxg9MB0SGg74A/jZJePnsEBSNvZvZk9t9E1pL0T1zkr/KLHZE=;
39
+ path=/; expires=Sun, 26-Feb-23 17:51:54 GMT; domain=.notion.com; HttpOnly;
40
+ Secure; SameSite=None
41
+ - notion_browser_id=1d39e7da-f4cd-4161-ac33-b489ee848b04; Domain=www.notion.so;
42
+ Path=/; Expires=Mon, 26 Feb 2024 17:21:53 GMT; Secure
43
+ - notion_check_cookie_consent=false; Domain=www.notion.so; Path=/; Expires=Mon,
44
+ 27 Feb 2023 17:21:53 GMT; Secure
45
+ Content-Security-Policy:
46
+ - "script-src 'self' 'unsafe-inline' 'unsafe-eval' https://gist.github.com https://apis.google.com
47
+ https://www.google.com https://www.gstatic.com https://cdn.amplitude.com https://api.amplitude.com
48
+ http://dev-embed.notion.co http://embed.notion.co https://widget.intercom.io
49
+ https://js.intercomcdn.com https://static.zdassets.com https://api.smooch.io\t
50
+ https://logs-01.loggly.com https://http-inputs-notion.splunkcloud.com https://cdn.segment.com
51
+ https://analytics.pgncs.notion.so https://o324374.ingest.sentry.io https://checkout.stripe.com
52
+ https://js.stripe.com https://embed.typeform.com https://admin.typeform.com
53
+ https://public.profitwell.com https://static.profitwell.com js.sentry-cdn.com
54
+ https://js.chilipiper.com https://platform.twitter.com https://cdn.syndication.twimg.com
55
+ https://accounts.google.com https://www.googletagmanager.com https://www.googleadservices.com
56
+ https://googleads.g.doubleclick.net https://api-v2.mutinyhq.io https://client-registry.mutinycdn.com
57
+ https://client.mutinycdn.com https://user-data.mutinycdn.com https://cdn.metadata.io
58
+ https://platformapi.metadata.io https://d2hrivdxn8ekm8.cloudfront.net https://d1lu3pmaz2ilpx.cloudfront.net
59
+ https://dvqigh9b7wa32.cloudfront.net https://d330aiyvva2oww.cloudfront.net
60
+ https://cdn.transcend.io https://cdn01.boxcdn.net https://cdn.sprig.com assets.customer.io
61
+ code.gist.build;connect-src 'self' data: blob: https://msgstore.www.notion.so
62
+ wss://msgstore.www.notion.so ws://localhost:* ws://127.0.0.1:* https://notion-emojis.s3-us-west-2.amazonaws.com
63
+ https://s3-us-west-2.amazonaws.com https://s3.us-west-2.amazonaws.com https://notion-production-snapshots-2.s3.us-west-2.amazonaws.com
64
+ https://cdn.amplitude.com https://api.amplitude.com https://www.notion.so
65
+ https://api.embed.ly http://dev-embed.notion.co http://embed.notion.co https://js.intercomcdn.com
66
+ https://api-iam.intercom.io https://uploads.intercomcdn.com wss://nexus-websocket-a.intercom.io
67
+ https://ekr.zdassets.com https://ekr.zendesk.com\t https://makenotion.zendesk.com\t
68
+ https://api.smooch.io\t wss://api.smooch.io\t https://logs-01.loggly.com https://http-inputs-notion.splunkcloud.com
69
+ https://cdn.segment.com https://api.segment.io https://analytics.pgncs.notion.so
70
+ https://api.pgncs.notion.so https://o324374.ingest.sentry.io https://checkout.stripe.com
71
+ https://js.stripe.com https://cdn.contentful.com https://preview.contentful.com
72
+ https://images.ctfassets.net https://www2.profitwell.com https://tracking.chilipiper.com
73
+ https://api.chilipiper.com https://api.unsplash.com https://boards-api.greenhouse.io
74
+ https://accounts.google.com https://oauth2.googleapis.com https://www.googletagmanager.com
75
+ https://analytics.google.com https://www.googleadservices.com https://googleads.g.doubleclick.net
76
+ https://region1.google-analytics.com https://region1.analytics.google.com
77
+ https://www.google-analytics.com https://api-v2.mutinyhq.io https://client-registry.mutinycdn.com
78
+ https://client.mutinycdn.com https://user-data.mutinycdn.com https://cdn.metadata.io
79
+ https://platformapi.metadata.io https://d2hrivdxn8ekm8.cloudfront.net https://d1lu3pmaz2ilpx.cloudfront.net
80
+ https://dvqigh9b7wa32.cloudfront.net https://d330aiyvva2oww.cloudfront.net
81
+ https://cdn.transcend.io https://telemetry.transcend.io https://api.statuspage.io
82
+ https://pgncd.notion.so https://api.statsig.com https://statsigapi.net https://exp.notion.so
83
+ https://file.notion.so notion://file.notion.so https://api.box.com https://*.mux.com
84
+ https://api.sprig.com https://storage.googleapis.com https://cdn.sprig.com
85
+ https://cdn.userleap.com track.customer.io *.api.gist.build *.cloud.gist.build;font-src
86
+ 'self' data: https://cdnjs.cloudflare.com https://js.intercomcdn.com https://cdn01.boxcdn.net;img-src
87
+ 'self' data: blob: https: https://platform.twitter.com https://syndication.twitter.com
88
+ https://pbs.twimg.com https://ton.twimg.com https://region1.google-analytics.com
89
+ https://region1.analytics.google.com https://file.notion.so notion://file.notion.so
90
+ https://*.mux.com track.customer.io;style-src 'self' 'unsafe-inline' https://cdnjs.cloudflare.com
91
+ https://github.githubassets.com https://js.chilipiper.com https://platform.twitter.com
92
+ https://ton.twimg.com https://accounts.google.com https://cdn.transcend.io
93
+ https://cdn01.boxcdn.net code.gist.build;media-src blob: https: http: https://file.notion.so
94
+ notion://file.notion.so https://*.mux.com;worker-src blob:;frame-src https:
95
+ http: https://accounts.google.com renderer.gist.build code.gist.build"
96
+ X-Dns-Prefetch-Control:
97
+ - 'off'
98
+ X-Frame-Options:
99
+ - SAMEORIGIN
100
+ Strict-Transport-Security:
101
+ - max-age=5184000; includeSubDomains
102
+ X-Download-Options:
103
+ - noopen
104
+ X-Content-Type-Options:
105
+ - nosniff
106
+ X-Permitted-Cross-Domain-Policies:
107
+ - none
108
+ Referrer-Policy:
109
+ - strict-origin-when-cross-origin
110
+ X-Xss-Protection:
111
+ - '0'
112
+ Etag:
113
+ - W/"31f-hsLSu/ULQ6imEDuQTPedr2r+doc"
114
+ Vary:
115
+ - Accept-Encoding
116
+ Cf-Cache-Status:
117
+ - DYNAMIC
118
+ Server:
119
+ - cloudflare
120
+ Cf-Ray:
121
+ - 79fa5c17e98d82f8-IAD
122
+ body:
123
+ encoding: UTF-8
124
+ string: '{"object":"page","id":"c40d2199-e67f-4e07-875d-29f6259e7101","created_time":"2023-02-26T17:21:00.000Z","last_edited_time":"2023-02-26T17:21:00.000Z","created_by":{"object":"user","id":"baa602ec-7138-420d-bce4-a7c6cf125aa4"},"last_edited_by":{"object":"user","id":"baa602ec-7138-420d-bce4-a7c6cf125aa4"},"cover":null,"icon":null,"parent":{"type":"page_id","page_id":"0593a719-ff2e-44aa-a14a-2bf169429284"},"archived":false,"properties":{"title":{"id":"title","type":"title","title":[{"type":"text","text":{"content":"Another
125
+ Notion page","link":null},"annotations":{"bold":false,"italic":false,"strikethrough":false,"underline":false,"code":false,"color":"default"},"plain_text":"Another
126
+ Notion page","href":null}]}},"url":"https://www.notion.so/Another-Notion-page-c40d2199e67f4e07875d29f6259e7101"}'
127
+ recorded_at: Sun, 26 Feb 2023 17:21:54 GMT
128
+ recorded_with: VCR 6.0.0
@@ -47,6 +47,47 @@ RSpec.describe Notion::Api::Endpoints::Pages do
47
47
  expect(response.properties.Name.title.first.plain_text).to eql 'Another Notion page'
48
48
  end
49
49
 
50
+ context 'when creating under parent page' do
51
+ let(:parent_page) { '0593a719-ff2e-44aa-a14a-2bf169429284' }
52
+ let(:properties) do
53
+ {
54
+ "title": [
55
+ {
56
+ "text": {
57
+ "content": 'Another Notion page'
58
+ }
59
+ }
60
+ ]
61
+ }
62
+ end
63
+ let(:children) do
64
+ [
65
+ {
66
+ "object": 'block',
67
+ "type": 'heading_2',
68
+ "heading_2": {
69
+ rich_text: [
70
+ {
71
+ type: 'text',
72
+ text: { content: 'My Heading 2' }
73
+ }
74
+ ]
75
+ }
76
+ }
77
+ ]
78
+ end
79
+
80
+ it 'creates', vcr: { cassette_name: 'create_page_with_parent_page' } do
81
+ response = client.create_page(
82
+ parent: { page_id: parent_page },
83
+ properties: properties,
84
+ children: children
85
+ )
86
+ expect(response.parent.page_id).to eql parent_page
87
+ expect(response.properties.title.title.first.plain_text).to eql 'Another Notion page'
88
+ end
89
+ end
90
+
50
91
  it 'updates', vcr: { cassette_name: 'update_page' } do
51
92
  properties = {
52
93
  "Name": [
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: notion-ruby-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.2
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-26 00:00:00.000000000 Z
11
+ date: 2023-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: dotenv
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: faraday
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -80,6 +66,20 @@ dependencies:
80
66
  - - "~>"
81
67
  - !ruby/object:Gem::Version
82
68
  version: '5'
69
+ - !ruby/object:Gem::Dependency
70
+ name: dotenv
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rake
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -249,6 +249,7 @@ files:
249
249
  - spec/fixtures/notion/create_discussion_comment.yml
250
250
  - spec/fixtures/notion/create_page.yml
251
251
  - spec/fixtures/notion/create_page_comment.yml
252
+ - spec/fixtures/notion/create_page_with_parent_page.yml
252
253
  - spec/fixtures/notion/database.yml
253
254
  - spec/fixtures/notion/database_query.yml
254
255
  - spec/fixtures/notion/delete_block.yml
@@ -311,6 +312,7 @@ test_files:
311
312
  - spec/fixtures/notion/create_discussion_comment.yml
312
313
  - spec/fixtures/notion/create_page.yml
313
314
  - spec/fixtures/notion/create_page_comment.yml
315
+ - spec/fixtures/notion/create_page_with_parent_page.yml
314
316
  - spec/fixtures/notion/database.yml
315
317
  - spec/fixtures/notion/database_query.yml
316
318
  - spec/fixtures/notion/delete_block.yml