notion-ruby-client 1.0.0 → 1.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: feb78b4f0ea816f89e61d9da9d1280e8d4d3565e0a71b1d611c2c58a1b5b7f67
4
- data.tar.gz: e21ab58acc5a8414bfaccf21071a68e3ab37b11933448faed332347f597bc89b
3
+ metadata.gz: 1a51902078e38a1689842f254fd2a33c05c9cf7ee7e516a0d74c79ae0cf06018
4
+ data.tar.gz: 74cd639ca5b12e5c58bbc6e80b31b23bb29fc858e51fff6564afb4cc8079c120
5
5
  SHA512:
6
- metadata.gz: 39b6ffaf9f003c928c8eb358237419f68a0578d84f8e7ce0e3eaa548afffd5754fe721696335c6476f7a02dbf0975b1d0095496eeaa6ef01bf658234efbf9882
7
- data.tar.gz: 9174977cdd22e7af3516a118d2c282f60bebaea8ef756d9cc0eef5cbcbfb5ef285cb6cadfe35e738c31b62778893257c0498d8150beae8d02ab495867c9c3610
6
+ metadata.gz: b44e81d8f7acdd44845dcfc785555830adf556fe74d2ad1795913b131470dce9e315ce41051c0144aeb38b6c4385f3be3da01e039cabd682521f3929351af605
7
+ data.tar.gz: 384c2a8dae62684800ec4af7dd52cc4c7b961f82a17e90e867e60bcdbc518e49a840b4c8707f5d76b5d7cc031f4c5c98e906913bb6e68bbaff64db409cfdf2d3
@@ -4,7 +4,7 @@ jobs:
4
4
  test:
5
5
  strategy:
6
6
  matrix:
7
- ruby: [2.5, 2.6, 2.7]
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,14 @@
1
+ ### 1.1.0 (2023-02-23)
2
+
3
+ #### Breaking changes
4
+
5
+ - Remove support for ruby 2.5
6
+ - Remove the `activesupport` dependency. Add `gem 'activesupport'` to your Gemfile if you required ActiveSupport via this library.
7
+
8
+ #### Other
9
+
10
+ - Upgrade Faraday to v2 (thanks @Tao-Galasse!)
11
+
1
12
  ### 1.0.0 (2022-03-30)
2
13
 
3
14
  #### New
data/Gemfile.lock CHANGED
@@ -1,62 +1,36 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- notion-ruby-client (1.0.0)
5
- activesupport (>= 6)
4
+ notion-ruby-client (1.1.0)
6
5
  dotenv
7
- faraday (>= 1.0)
8
- faraday_middleware
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.7.6)
28
- faraday (1.10.0)
29
- faraday-em_http (~> 1.0)
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-em_http (1.0.0)
41
- faraday-em_synchrony (1.0.0)
42
- faraday-excon (1.1.0)
43
- faraday-httpclient (1.0.1)
44
- faraday-multipart (1.0.3)
45
- multipart-post (>= 1.2, < 3)
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
- minitest (5.15.0)
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
@@ -129,9 +129,9 @@ client.database_query(database_id: 'e383bcee-e0d8-4564-9c63-900d307abdb0') do |p
129
129
  end
130
130
 
131
131
  # Filter and sort the database
132
- sort = [
132
+ sorts = [
133
133
  {
134
- 'property': 'Last ordered',
134
+ 'timestamp': 'created_time',
135
135
  'direction': 'ascending'
136
136
  }
137
137
  ]
@@ -151,7 +151,7 @@ filter = {
151
151
  }
152
152
  ]
153
153
  }
154
- client.database_query(database_id: 'e383bcee-e0d8-4564-9c63-900d307abdb0', sort: sort, filter: filter)
154
+ client.database_query(database_id: 'e383bcee-e0d8-4564-9c63-900d307abdb0', sorts: sorts, filter: filter)
155
155
  ```
156
156
 
157
157
  See [Pagination](#pagination) for details about how to iterate through the list.
@@ -273,7 +273,7 @@ See the full endpoint documentation on [Notion Developers](https://developers.no
273
273
 
274
274
  Creates a new page in the specified database or as a child of an existing page.
275
275
 
276
- If the parent is a database, the [property values](https://developers.notion.com/reference-link/page-property-value) of the new page in the properties parameter must conform to the parent [database](https://developers.notion.com/reference-link/database)'s property schema.
276
+ 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
277
 
278
278
  If the parent is a page, the only valid property is `title`.
279
279
 
@@ -314,14 +314,14 @@ children = [
314
314
  'type': 'heading_2',
315
315
  'heading_2': {
316
316
  'rich_text': [{
317
- 'type": 'text',
317
+ 'type': 'text',
318
318
  'text': { 'content': 'Lacinato kale' }
319
319
  }]
320
320
  }
321
321
  },
322
322
  {
323
323
  'object': 'block',
324
- 'type": 'paragraph',
324
+ 'type': 'paragraph',
325
325
  'paragraph': {
326
326
  'rich_text': [
327
327
  {
@@ -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
- throw ArgumentError.new('Required arguments :block_id missing') if options[:block_id].nil?
32
- patch("blocks/#{options[:block_id]}", options.except(:block_id))
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
- get("blocks/#{options[:block_id]}/children", options.except(:block_id))
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
- throw ArgumentError.new('Required arguments :block_id missing') if options[:block_id].nil?
92
- patch("blocks/#{options[:block_id]}/children", options.except(:block_id))
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
@@ -40,7 +40,8 @@ module Notion
40
40
  yield page
41
41
  end
42
42
  else
43
- post("databases/#{options[:database_id]}/query", options.except(:database_id))
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
- throw ArgumentError.new('Required arguments :database_id missing') if options.dig(:database_id).nil?
88
- patch("databases/#{options[:database_id]}", options.except(:database_id))
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
- throw ArgumentError.new('Required argument :page_id missing') if options[:page_id].nil?
64
- patch("pages/#{options[:page_id]}", options.except(:page_id))
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/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 = defined?(OpenSSL) ? OpenSSL::X509::DEFAULT_CERT_DIR : nil
28
- self.ca_file = defined?(OpenSSL) ? OpenSSL::X509::DEFAULT_CERT_FILE : nil
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::Request::Multipart
24
+ connection.use ::Faraday::Multipart::Middleware
25
25
  connection.use ::Faraday::Request::UrlEncoded
26
26
  connection.use ::Notion::Faraday::Response::RaiseError
27
- connection.use ::FaradayMiddleware::Mashify, mash_class: Notion::Messages::Message
28
- connection.use ::FaradayMiddleware::ParseJson
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
@@ -42,4 +42,4 @@ module Notion
42
42
  end
43
43
  end
44
44
  end
45
- end
45
+ end
@@ -2,7 +2,7 @@
2
2
  module Notion
3
3
  module Faraday
4
4
  module Response
5
- class RaiseError < ::Faraday::Response::Middleware
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::Middleware
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  module Notion
3
- VERSION = '1.0.0'
3
+ VERSION = '1.1.0'
4
4
  NOTION_REQUEST_VERSION = '2022-02-22'
5
5
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
- require 'active_support/core_ext/hash/except'
3
2
  require 'faraday'
4
- require 'faraday_middleware'
3
+ require 'faraday/mashify'
4
+ require 'faraday/multipart'
5
5
  require 'json'
6
6
  require 'logger'
7
7
  require 'hashie'
@@ -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', '>= 1.0'
21
- s.add_dependency 'faraday_middleware'
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'
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.0.0
4
+ version: 1.1.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: 2022-03-30 00:00:00.000000000 Z
11
+ date: 2023-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: activesupport
14
+ name: dotenv
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '6'
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: '6'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: dotenv
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: '1.0'
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: '1.0'
54
+ version: 0.1.1
55
55
  - !ruby/object:Gem::Dependency
56
- name: faraday_middleware
56
+ name: faraday-multipart
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
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: '0'
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"