notion-client-ruby 0.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 +7 -0
- data/.env.example +8 -0
- data/LICENSE.txt +21 -0
- data/README.md +95 -0
- data/Rakefile +120 -0
- data/benchmark/load.rb +9 -0
- data/benchmark/objects.rb +14 -0
- data/codegen/generator.rb +277 -0
- data/codegen/naming.yml +61 -0
- data/codegen/openapi.json +47206 -0
- data/codegen/openapi.lock +1 -0
- data/codegen/overrides.yml +14 -0
- data/docs/design.md +7 -0
- data/docs/recipes/csv-import.md +14 -0
- data/docs/recipes/oauth.md +9 -0
- data/docs/recipes/page-sync.md +10 -0
- data/docs/recipes/pagination.md +9 -0
- data/docs/recipes/uploads.md +9 -0
- data/docs/recipes/webhooks.md +28 -0
- data/lib/generators/notion/install_generator.rb +15 -0
- data/lib/generators/notion/templates/notion.rb +5 -0
- data/lib/notion/batch.rb +45 -0
- data/lib/notion/blocks/builder.rb +57 -0
- data/lib/notion/blocks/chunker.rb +70 -0
- data/lib/notion/blocks.rb +4 -0
- data/lib/notion/client.rb +138 -0
- data/lib/notion/compat/legacy.rb +47 -0
- data/lib/notion/compat.rb +94 -0
- data/lib/notion/config.rb +88 -0
- data/lib/notion/endpoints/async_tasks.rb +26 -0
- data/lib/notion/endpoints/base.rb +107 -0
- data/lib/notion/endpoints/blocks.rb +39 -0
- data/lib/notion/endpoints/data_sources.rb +30 -0
- data/lib/notion/endpoints/file_uploads.rb +35 -0
- data/lib/notion/endpoints/pages.rb +56 -0
- data/lib/notion/endpoints/views.rb +16 -0
- data/lib/notion/errors.rb +111 -0
- data/lib/notion/experimental.rb +12 -0
- data/lib/notion/file_uploader.rb +142 -0
- data/lib/notion/generated/endpoints/agents.rb +64 -0
- data/lib/notion/generated/endpoints/async_tasks.rb +20 -0
- data/lib/notion/generated/endpoints/blocks.rb +49 -0
- data/lib/notion/generated/endpoints/comments.rb +48 -0
- data/lib/notion/generated/endpoints/custom_emojis.rb +20 -0
- data/lib/notion/generated/endpoints/data_sources.rb +49 -0
- data/lib/notion/generated/endpoints/databases.rb +34 -0
- data/lib/notion/generated/endpoints/file_uploads.rb +51 -0
- data/lib/notion/generated/endpoints/meeting_notes.rb +27 -0
- data/lib/notion/generated/endpoints/oauth.rb +34 -0
- data/lib/notion/generated/endpoints/pages.rb +65 -0
- data/lib/notion/generated/endpoints/search.rb +20 -0
- data/lib/notion/generated/endpoints/sessions.rb +48 -0
- data/lib/notion/generated/endpoints/users.rb +34 -0
- data/lib/notion/generated/endpoints/views.rb +73 -0
- data/lib/notion/generated.rb +41 -0
- data/lib/notion/id.rb +14 -0
- data/lib/notion/markdown/local_converter.rb +34 -0
- data/lib/notion/middleware/api_version.rb +18 -0
- data/lib/notion/middleware/authentication.rb +52 -0
- data/lib/notion/middleware/compatibility.rb +17 -0
- data/lib/notion/middleware/instrumentation.rb +63 -0
- data/lib/notion/middleware/json_codec.rb +37 -0
- data/lib/notion/middleware/logging.rb +36 -0
- data/lib/notion/middleware/rate_limiter.rb +78 -0
- data/lib/notion/middleware/retry.rb +45 -0
- data/lib/notion/middleware/stack.rb +20 -0
- data/lib/notion/middleware.rb +11 -0
- data/lib/notion/multipart.rb +39 -0
- data/lib/notion/oauth.rb +91 -0
- data/lib/notion/object_factory.rb +39 -0
- data/lib/notion/objects/base.rb +62 -0
- data/lib/notion/objects/list.rb +56 -0
- data/lib/notion/objects/property_schema.rb +57 -0
- data/lib/notion/objects/property_value.rb +56 -0
- data/lib/notion/objects/types.rb +56 -0
- data/lib/notion/objects.rb +8 -0
- data/lib/notion/pagination/cursor_paginator.rb +25 -0
- data/lib/notion/query/builder.rb +117 -0
- data/lib/notion/query.rb +3 -0
- data/lib/notion/railtie.rb +11 -0
- data/lib/notion/resolver.rb +72 -0
- data/lib/notion/testing.rb +45 -0
- data/lib/notion/transport/net_http_adapter.rb +90 -0
- data/lib/notion/transport.rb +21 -0
- data/lib/notion/version.rb +5 -0
- data/lib/notion/webhooks/event.rb +7 -0
- data/lib/notion/webhooks/rack_middleware.rb +43 -0
- data/lib/notion/webhooks/signature.rb +22 -0
- data/lib/notion/webhooks.rb +7 -0
- data/lib/notion-client-ruby.rb +3 -0
- data/lib/notion.rb +53 -0
- metadata +132 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "openssl"
|
|
4
|
+
|
|
5
|
+
module Notion
|
|
6
|
+
module Webhooks
|
|
7
|
+
module Signature
|
|
8
|
+
module_function
|
|
9
|
+
|
|
10
|
+
def valid?(secret:, payload:, signature:)
|
|
11
|
+
expected = OpenSSL::HMAC.hexdigest("SHA256", secret, payload)
|
|
12
|
+
secure_compare?(expected, signature.to_s.delete_prefix("sha256="))
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def secure_compare?(left, right)
|
|
16
|
+
return false unless left.bytesize == right.bytesize
|
|
17
|
+
|
|
18
|
+
left.bytes.zip(right.bytes).reduce(0) { |difference, (a, b)| difference | (a ^ b) }.zero?
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
data/lib/notion.rb
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "notion/version"
|
|
4
|
+
require_relative "notion/config"
|
|
5
|
+
require_relative "notion/errors"
|
|
6
|
+
require_relative "notion/railtie"
|
|
7
|
+
|
|
8
|
+
module Notion
|
|
9
|
+
LATEST_API_VERSION = "2026-03-11"
|
|
10
|
+
|
|
11
|
+
autoload :Blocks, "notion/blocks"
|
|
12
|
+
autoload :Batch, "notion/batch"
|
|
13
|
+
autoload :Client, "notion/client"
|
|
14
|
+
autoload :Compat, "notion/compat"
|
|
15
|
+
autoload :FileUploader, "notion/file_uploader"
|
|
16
|
+
autoload :Generated, "notion/client"
|
|
17
|
+
autoload :ID, "notion/id"
|
|
18
|
+
autoload :Markdown, "notion/markdown/local_converter"
|
|
19
|
+
autoload :Middleware, "notion/middleware"
|
|
20
|
+
autoload :Multipart, "notion/multipart"
|
|
21
|
+
autoload :ObjectFactory, "notion/object_factory"
|
|
22
|
+
autoload :Objects, "notion/objects"
|
|
23
|
+
autoload :OAuth, "notion/oauth"
|
|
24
|
+
autoload :Pagination, "notion/pagination/cursor_paginator"
|
|
25
|
+
autoload :Query, "notion/query"
|
|
26
|
+
autoload :Resolver, "notion/resolver"
|
|
27
|
+
autoload :Testing, "notion/testing"
|
|
28
|
+
autoload :Transport, "notion/transport"
|
|
29
|
+
autoload :Webhooks, "notion/webhooks"
|
|
30
|
+
|
|
31
|
+
class << self
|
|
32
|
+
def configuration
|
|
33
|
+
@configuration ||= Config.new
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def configure
|
|
37
|
+
yield(configuration)
|
|
38
|
+
configuration.validate!
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def new(**options)
|
|
42
|
+
Client.new(**options)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def blocks(&)
|
|
46
|
+
Blocks::Builder.build(&)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def reset_configuration!
|
|
50
|
+
@configuration = Config.new
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: notion-client-ruby
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Yudai Takada
|
|
8
|
+
bindir: exe
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
12
|
+
description: A resilient Ruby client for current and legacy Notion Public API versions.
|
|
13
|
+
email:
|
|
14
|
+
- t.yudai92@gmail.com
|
|
15
|
+
executables: []
|
|
16
|
+
extensions: []
|
|
17
|
+
extra_rdoc_files: []
|
|
18
|
+
files:
|
|
19
|
+
- ".env.example"
|
|
20
|
+
- LICENSE.txt
|
|
21
|
+
- README.md
|
|
22
|
+
- Rakefile
|
|
23
|
+
- benchmark/load.rb
|
|
24
|
+
- benchmark/objects.rb
|
|
25
|
+
- codegen/generator.rb
|
|
26
|
+
- codegen/naming.yml
|
|
27
|
+
- codegen/openapi.json
|
|
28
|
+
- codegen/openapi.lock
|
|
29
|
+
- codegen/overrides.yml
|
|
30
|
+
- docs/design.md
|
|
31
|
+
- docs/recipes/csv-import.md
|
|
32
|
+
- docs/recipes/oauth.md
|
|
33
|
+
- docs/recipes/page-sync.md
|
|
34
|
+
- docs/recipes/pagination.md
|
|
35
|
+
- docs/recipes/uploads.md
|
|
36
|
+
- docs/recipes/webhooks.md
|
|
37
|
+
- lib/generators/notion/install_generator.rb
|
|
38
|
+
- lib/generators/notion/templates/notion.rb
|
|
39
|
+
- lib/notion-client-ruby.rb
|
|
40
|
+
- lib/notion.rb
|
|
41
|
+
- lib/notion/batch.rb
|
|
42
|
+
- lib/notion/blocks.rb
|
|
43
|
+
- lib/notion/blocks/builder.rb
|
|
44
|
+
- lib/notion/blocks/chunker.rb
|
|
45
|
+
- lib/notion/client.rb
|
|
46
|
+
- lib/notion/compat.rb
|
|
47
|
+
- lib/notion/compat/legacy.rb
|
|
48
|
+
- lib/notion/config.rb
|
|
49
|
+
- lib/notion/endpoints/async_tasks.rb
|
|
50
|
+
- lib/notion/endpoints/base.rb
|
|
51
|
+
- lib/notion/endpoints/blocks.rb
|
|
52
|
+
- lib/notion/endpoints/data_sources.rb
|
|
53
|
+
- lib/notion/endpoints/file_uploads.rb
|
|
54
|
+
- lib/notion/endpoints/pages.rb
|
|
55
|
+
- lib/notion/endpoints/views.rb
|
|
56
|
+
- lib/notion/errors.rb
|
|
57
|
+
- lib/notion/experimental.rb
|
|
58
|
+
- lib/notion/file_uploader.rb
|
|
59
|
+
- lib/notion/generated.rb
|
|
60
|
+
- lib/notion/generated/endpoints/agents.rb
|
|
61
|
+
- lib/notion/generated/endpoints/async_tasks.rb
|
|
62
|
+
- lib/notion/generated/endpoints/blocks.rb
|
|
63
|
+
- lib/notion/generated/endpoints/comments.rb
|
|
64
|
+
- lib/notion/generated/endpoints/custom_emojis.rb
|
|
65
|
+
- lib/notion/generated/endpoints/data_sources.rb
|
|
66
|
+
- lib/notion/generated/endpoints/databases.rb
|
|
67
|
+
- lib/notion/generated/endpoints/file_uploads.rb
|
|
68
|
+
- lib/notion/generated/endpoints/meeting_notes.rb
|
|
69
|
+
- lib/notion/generated/endpoints/oauth.rb
|
|
70
|
+
- lib/notion/generated/endpoints/pages.rb
|
|
71
|
+
- lib/notion/generated/endpoints/search.rb
|
|
72
|
+
- lib/notion/generated/endpoints/sessions.rb
|
|
73
|
+
- lib/notion/generated/endpoints/users.rb
|
|
74
|
+
- lib/notion/generated/endpoints/views.rb
|
|
75
|
+
- lib/notion/id.rb
|
|
76
|
+
- lib/notion/markdown/local_converter.rb
|
|
77
|
+
- lib/notion/middleware.rb
|
|
78
|
+
- lib/notion/middleware/api_version.rb
|
|
79
|
+
- lib/notion/middleware/authentication.rb
|
|
80
|
+
- lib/notion/middleware/compatibility.rb
|
|
81
|
+
- lib/notion/middleware/instrumentation.rb
|
|
82
|
+
- lib/notion/middleware/json_codec.rb
|
|
83
|
+
- lib/notion/middleware/logging.rb
|
|
84
|
+
- lib/notion/middleware/rate_limiter.rb
|
|
85
|
+
- lib/notion/middleware/retry.rb
|
|
86
|
+
- lib/notion/middleware/stack.rb
|
|
87
|
+
- lib/notion/multipart.rb
|
|
88
|
+
- lib/notion/oauth.rb
|
|
89
|
+
- lib/notion/object_factory.rb
|
|
90
|
+
- lib/notion/objects.rb
|
|
91
|
+
- lib/notion/objects/base.rb
|
|
92
|
+
- lib/notion/objects/list.rb
|
|
93
|
+
- lib/notion/objects/property_schema.rb
|
|
94
|
+
- lib/notion/objects/property_value.rb
|
|
95
|
+
- lib/notion/objects/types.rb
|
|
96
|
+
- lib/notion/pagination/cursor_paginator.rb
|
|
97
|
+
- lib/notion/query.rb
|
|
98
|
+
- lib/notion/query/builder.rb
|
|
99
|
+
- lib/notion/railtie.rb
|
|
100
|
+
- lib/notion/resolver.rb
|
|
101
|
+
- lib/notion/testing.rb
|
|
102
|
+
- lib/notion/transport.rb
|
|
103
|
+
- lib/notion/transport/net_http_adapter.rb
|
|
104
|
+
- lib/notion/version.rb
|
|
105
|
+
- lib/notion/webhooks.rb
|
|
106
|
+
- lib/notion/webhooks/event.rb
|
|
107
|
+
- lib/notion/webhooks/rack_middleware.rb
|
|
108
|
+
- lib/notion/webhooks/signature.rb
|
|
109
|
+
homepage: https://rubygems.org/gems/notion-client-ruby
|
|
110
|
+
licenses:
|
|
111
|
+
- MIT
|
|
112
|
+
metadata:
|
|
113
|
+
allowed_push_host: https://rubygems.org
|
|
114
|
+
rubygems_mfa_required: 'true'
|
|
115
|
+
rdoc_options: []
|
|
116
|
+
require_paths:
|
|
117
|
+
- lib
|
|
118
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
119
|
+
requirements:
|
|
120
|
+
- - ">="
|
|
121
|
+
- !ruby/object:Gem::Version
|
|
122
|
+
version: 3.2.0
|
|
123
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
|
+
requirements:
|
|
125
|
+
- - ">="
|
|
126
|
+
- !ruby/object:Gem::Version
|
|
127
|
+
version: '0'
|
|
128
|
+
requirements: []
|
|
129
|
+
rubygems_version: 4.0.19
|
|
130
|
+
specification_version: 4
|
|
131
|
+
summary: A modern, dependency-free Ruby client for the Notion API
|
|
132
|
+
test_files: []
|