notion_ruby_mapping 3.0.5 → 4.0.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/README.md +1 -0
- data/lib/notion_ruby_mapping/blocks/base.rb +26 -7
- data/lib/notion_ruby_mapping/blocks/block.rb +4 -2
- data/lib/notion_ruby_mapping/blocks/data_source.rb +17 -4
- data/lib/notion_ruby_mapping/blocks/heading4_block.rb +26 -0
- data/lib/notion_ruby_mapping/blocks/list.rb +8 -1
- data/lib/notion_ruby_mapping/blocks/page.rb +69 -0
- data/lib/notion_ruby_mapping/blocks/toggle_heading4_block.rb +19 -0
- data/lib/notion_ruby_mapping/controllers/notion_cache.rb +46 -1
- data/lib/notion_ruby_mapping/objects/template_object.rb +19 -0
- data/lib/notion_ruby_mapping/properties/property.rb +1 -1
- data/lib/notion_ruby_mapping/properties/verification_property.rb +11 -0
- data/lib/notion_ruby_mapping/version.rb +2 -2
- data/lib/notion_ruby_mapping.rb +2 -2
- data/notion_ruby_mapping.gemspec +3 -0
- metadata +47 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9dad5c3579a84ff3dd64c56a20d58e1c8bdcd605d6d956b7a97f3a6120bee28a
|
|
4
|
+
data.tar.gz: fffec11062ce3e152350cda495ad33b13baf2697abb7db308b4755e66710654e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bc60d84f2634660338b0ffee697539e9063b4e46e079c5a107724f1acd782e466bbc27b80561b710dcaf2a9878194a5b0a77bcf52edf4028e142d3b24a636767
|
|
7
|
+
data.tar.gz: d7e39e143665cd7c51ebd8008e727aacdaee9ee936f043017c7e163b4db078c253a189dc391baead83061b1ae0656a9c33c5d278e5269e6f2b871a774c061c16
|
data/README.md
CHANGED
|
@@ -136,6 +136,7 @@ NotionRubyMapping.configuration { |c| c.notion_token = ENV["NOTION_API_TOKEN"] }
|
|
|
136
136
|
|
|
137
137
|
## 3. ChangeLog
|
|
138
138
|
|
|
139
|
+
- 2026/1/25 [v3.0.6] add move page, list templates, and create child page to page
|
|
139
140
|
- 2025/12/15 [v3.0.5] add AudioBlock
|
|
140
141
|
- 2025/12/9 [v3.0.4] Fix the issue where page.parent could not be executed for pages with a data source as parent
|
|
141
142
|
- 2025/10/25 [v3.0.3] Add default template option for create_child_page and build_child_page
|
|
@@ -7,11 +7,15 @@ module NotionRubyMapping
|
|
|
7
7
|
# @param [Hash, nil] json
|
|
8
8
|
# @param [String, nil] id
|
|
9
9
|
# @param [Array<Property, Class, String>] assign
|
|
10
|
-
|
|
10
|
+
# @param [Block, nil] parent
|
|
11
|
+
# @param [String, nil] template_page
|
|
12
|
+
# @param [String, nil] position
|
|
13
|
+
# @param [String, nil] markdown
|
|
14
|
+
def initialize(json: nil, id: nil, assign: [], parent: nil, template_page: nil, position: nil, markdown: nil)
|
|
11
15
|
@nc = NotionCache.instance
|
|
12
16
|
@json = json
|
|
13
17
|
@id = @nc.hex_id(id || @json && @json["id"])
|
|
14
|
-
@
|
|
18
|
+
@in_trash = @json && @json["in_trash"]
|
|
15
19
|
@has_children = @json && @json["has_children"]
|
|
16
20
|
@new_record = true unless parent.nil?
|
|
17
21
|
raise StandardError, "Unknown id" if !is_a?(List) && !is_a?(Block) && @id.nil? && parent.nil?
|
|
@@ -23,6 +27,12 @@ module NotionRubyMapping
|
|
|
23
27
|
elsif template_page
|
|
24
28
|
payload_json["template"] = {"type" => "template_id", "template_id" => template_page.id}
|
|
25
29
|
end
|
|
30
|
+
if %w[page_start page_end].include? position
|
|
31
|
+
payload_json["position"] = {"type" => position}
|
|
32
|
+
elsif position
|
|
33
|
+
payload_json["position"] = {"type" => "after_block", "after_block" => {"id" => position}}
|
|
34
|
+
end
|
|
35
|
+
payload_json["markdown"] = markdown if markdown
|
|
26
36
|
@payload = Payload.new(payload_json)
|
|
27
37
|
@property_cache = nil
|
|
28
38
|
@created_time = nil
|
|
@@ -32,13 +42,13 @@ module NotionRubyMapping
|
|
|
32
42
|
assign.each_slice(2) { |(klass, key)| assign_property(klass, key) }
|
|
33
43
|
@json ||= {}
|
|
34
44
|
end
|
|
35
|
-
attr_reader :json, :id, :
|
|
45
|
+
attr_reader :json, :id, :in_trash, :has_children
|
|
36
46
|
|
|
37
47
|
# @param [Hash, Notion::Messages] json
|
|
38
48
|
# @return [NotionRubyMapping::Base]
|
|
39
49
|
def self.create_from_json(json)
|
|
40
50
|
case json["object"]
|
|
41
|
-
when "page"
|
|
51
|
+
when "page", "page_markdown"
|
|
42
52
|
Page.new json: json
|
|
43
53
|
when "data_source"
|
|
44
54
|
DataSource.new json: json
|
|
@@ -135,12 +145,12 @@ module NotionRubyMapping
|
|
|
135
145
|
end
|
|
136
146
|
|
|
137
147
|
# @param [Array<Block>] blocks
|
|
138
|
-
# @param [String, nil]
|
|
148
|
+
# @param [String, nil] position block id of previous block, start, or end
|
|
139
149
|
# @param [Boolean] dry_run true if dry_run
|
|
140
150
|
# @return [NotionRubyMapping::Block, String]
|
|
141
151
|
# @see https://www.notion.so/hkob/Page-d359650e3ca94424af8359a24147b9a0#44bbf83d852c419485c5efe9fe1558fb
|
|
142
152
|
# @see https://www.notion.so/hkob/Block-689ad4cbff50404d8a1baf67b6d6d78d#2c47f7fedae543cf8566389ba1677132
|
|
143
|
-
def append_block_children(*blocks,
|
|
153
|
+
def append_block_children(*blocks, position: nil, dry_run: false)
|
|
144
154
|
raise StandardError, "This block can have no children." unless page? || (block? && can_have_children)
|
|
145
155
|
|
|
146
156
|
only_one = blocks.length == 1
|
|
@@ -150,7 +160,11 @@ module NotionRubyMapping
|
|
|
150
160
|
block.block_json
|
|
151
161
|
end,
|
|
152
162
|
}
|
|
153
|
-
|
|
163
|
+
if %w[start end].include? position
|
|
164
|
+
json["position"] = {"type" => position}
|
|
165
|
+
elsif position
|
|
166
|
+
json["position"] = {"type" => "after_block", "after_block" => {"id" => position}}
|
|
167
|
+
end
|
|
154
168
|
if dry_run
|
|
155
169
|
path = @nc.append_block_children_page_path(id)
|
|
156
170
|
self.class.dry_run_script :patch, path, json
|
|
@@ -261,6 +275,11 @@ module NotionRubyMapping
|
|
|
261
275
|
@last_edited_time ||= LastEditedTimeProperty.new("__timestamp__", json: self["last_edited_time"])
|
|
262
276
|
end
|
|
263
277
|
|
|
278
|
+
# @return [String]
|
|
279
|
+
def markdown
|
|
280
|
+
@json && @json["markdown"]
|
|
281
|
+
end
|
|
282
|
+
|
|
264
283
|
# @return [Boolean] true if new record
|
|
265
284
|
# @see https://www.notion.so/hkob/Page-d359650e3ca94424af8359a24147b9a0#307af6e40d3840c59f8a82513a572d51
|
|
266
285
|
def new_record?
|
|
@@ -34,6 +34,7 @@ module NotionRubyMapping
|
|
|
34
34
|
heading_1: Heading1Block,
|
|
35
35
|
heading_2: Heading2Block,
|
|
36
36
|
heading_3: Heading3Block,
|
|
37
|
+
heading_4: Heading4Block,
|
|
37
38
|
image: ImageBlock,
|
|
38
39
|
link_preview: LinkPreviewBlock,
|
|
39
40
|
link_to_page: LinkToPageBlock,
|
|
@@ -53,6 +54,7 @@ module NotionRubyMapping
|
|
|
53
54
|
heading_1: ToggleHeading1Block,
|
|
54
55
|
heading_2: ToggleHeading2Block,
|
|
55
56
|
heading_3: ToggleHeading3Block,
|
|
57
|
+
heading_4: ToggleHeading4Block,
|
|
56
58
|
},
|
|
57
59
|
}
|
|
58
60
|
@klass = @type2class[has_children][type.to_sym] || @type2class[false][type.to_sym] || Block
|
|
@@ -80,7 +82,7 @@ module NotionRubyMapping
|
|
|
80
82
|
# @return [NotionRubyMapping::Block, String]
|
|
81
83
|
# @param [Array<Block>] blocks
|
|
82
84
|
def append_after(*blocks, dry_run: false)
|
|
83
|
-
parent.append_block_children(*blocks,
|
|
85
|
+
parent.append_block_children(*blocks, position: id, dry_run: dry_run)
|
|
84
86
|
end
|
|
85
87
|
|
|
86
88
|
# @param [Boolean] not_update false when update
|
|
@@ -88,7 +90,7 @@ module NotionRubyMapping
|
|
|
88
90
|
def block_json(not_update: true)
|
|
89
91
|
ans = {"type" => type}
|
|
90
92
|
ans["object"] = "block"
|
|
91
|
-
ans["
|
|
93
|
+
ans["in_trash"] = true if @in_trash
|
|
92
94
|
ans
|
|
93
95
|
end
|
|
94
96
|
|
|
@@ -40,9 +40,12 @@ module NotionRubyMapping
|
|
|
40
40
|
# @param [Array<Property, Class, String>] assign
|
|
41
41
|
# @return [NotionRubyMapping::Base]
|
|
42
42
|
# @see https://www.notion.so/hkob/DataSource-1462b24502424539a4231bedc07dc2f5#c217ce78020a4de79b720790fce3092d
|
|
43
|
-
|
|
43
|
+
# @param [String, NilClass] template_page
|
|
44
|
+
# @param [String, NilClass] markdown
|
|
45
|
+
def build_child_page(*assign, template_page: nil, markdown: nil)
|
|
44
46
|
assign = properties.map { |p| [p.class, p.name] }.flatten if assign.empty?
|
|
45
|
-
page = Page.new assign: assign, parent: {"data_source_id" => @id}, template_page: template_page
|
|
47
|
+
page = Page.new assign: assign, parent: {"data_source_id" => @id}, template_page: template_page,
|
|
48
|
+
markdown: markdown
|
|
46
49
|
pp = page.properties
|
|
47
50
|
pp.clear_will_update
|
|
48
51
|
yield page, pp if block_given?
|
|
@@ -50,12 +53,15 @@ module NotionRubyMapping
|
|
|
50
53
|
end
|
|
51
54
|
|
|
52
55
|
# @param [Array<Property, Class, String>] assign
|
|
56
|
+
# @param [String, NilClass] template_page
|
|
57
|
+
# @param [String, NilClass] markdown
|
|
53
58
|
# @param [Boolean] dry_run true if dry_run
|
|
54
59
|
# @return [NotionRubyMapping::Base]
|
|
55
60
|
# @see https://www.notion.so/hkob/DataSource-1462b24502424539a4231bedc07dc2f5#c217ce78020a4de79b720790fce3092d
|
|
56
|
-
def create_child_page(*assign, template_page: nil, dry_run: false)
|
|
61
|
+
def create_child_page(*assign, template_page: nil, markdown: nil, dry_run: false)
|
|
57
62
|
assign = properties.map { |p| [p.class, p.name] }.flatten if assign.empty?
|
|
58
|
-
page = Page.new assign: assign, parent: {"data_source_id" => @id}, template_page: template_page
|
|
63
|
+
page = Page.new assign: assign, parent: {"data_source_id" => @id}, template_page: template_page,
|
|
64
|
+
markdown: markdown
|
|
59
65
|
pp = page.properties
|
|
60
66
|
pp.clear_will_update
|
|
61
67
|
yield page, pp if block_given?
|
|
@@ -126,6 +132,13 @@ module NotionRubyMapping
|
|
|
126
132
|
self
|
|
127
133
|
end
|
|
128
134
|
|
|
135
|
+
# @param [Integer] page_size
|
|
136
|
+
# @return [NotionRubyMapping::List] List of Template object
|
|
137
|
+
def templates(page_size: nil)
|
|
138
|
+
json = @nc.list_data_source_templates_request(id, page_size: page_size)
|
|
139
|
+
List.new type: "template", value: id, json: json, query: Query.new
|
|
140
|
+
end
|
|
141
|
+
|
|
129
142
|
# @return [Hash] created json for property schemas (for update data_source)
|
|
130
143
|
def update_property_schema_json
|
|
131
144
|
@payload.update_property_schema_json @property_cache, data_source_title
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module NotionRubyMapping
|
|
4
|
+
# Notion block
|
|
5
|
+
class Heading4Block < TextSubBlockColorBaseBlock
|
|
6
|
+
# @param [RichTextArray, String, Array<String>, RichTextObject, Array<RichTextObject>] text_info
|
|
7
|
+
# @param [String] color
|
|
8
|
+
def initialize(text_info = nil, color: nil, json: nil, id: nil, parent: nil)
|
|
9
|
+
super(text_info, color: color, json: json, id: id, parent: parent)
|
|
10
|
+
@can_have_children = false
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# @return [String]
|
|
14
|
+
def type
|
|
15
|
+
"heading_4"
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# @param [Boolean] not_update false when update
|
|
19
|
+
# @return [Hash{String (frozen)->Hash}]
|
|
20
|
+
def block_json(not_update: true)
|
|
21
|
+
ans = super
|
|
22
|
+
ans[type]["is_toggleable"] = false
|
|
23
|
+
ans
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -23,6 +23,8 @@ module NotionRubyMapping
|
|
|
23
23
|
@user_object = value
|
|
24
24
|
when "search"
|
|
25
25
|
@search = value
|
|
26
|
+
when "template"
|
|
27
|
+
@template = value
|
|
26
28
|
end
|
|
27
29
|
@query = query
|
|
28
30
|
@index = 0
|
|
@@ -82,6 +84,11 @@ module NotionRubyMapping
|
|
|
82
84
|
query: -> { @nc.search @search.payload.merge(@query.query_json) },
|
|
83
85
|
create_object: ->(json) { Base.create_from_json json },
|
|
84
86
|
&block
|
|
87
|
+
elsif @template
|
|
88
|
+
each_sub base: @template,
|
|
89
|
+
query: -> { @nc.list_data_source_templates_request @template, start_cursor: @query.start_cursor },
|
|
90
|
+
create_object: ->(json) { TemplateObject.new json: json },
|
|
91
|
+
&block
|
|
85
92
|
end
|
|
86
93
|
self
|
|
87
94
|
end
|
|
@@ -125,7 +132,7 @@ module NotionRubyMapping
|
|
|
125
132
|
|
|
126
133
|
# @return [Hash]
|
|
127
134
|
def results
|
|
128
|
-
@json["results"]
|
|
135
|
+
@json[@template ? "templates" : "results"]
|
|
129
136
|
end
|
|
130
137
|
end
|
|
131
138
|
end
|
|
@@ -59,11 +59,80 @@ module NotionRubyMapping
|
|
|
59
59
|
db.save dry_run: dry_run
|
|
60
60
|
end
|
|
61
61
|
|
|
62
|
+
# @return [NotionRubyMapping::Base]
|
|
63
|
+
# @param [String, NilClass] template_page
|
|
64
|
+
# @param [String, NilClass] position
|
|
65
|
+
# @param [String, NilClass] markdown
|
|
66
|
+
def build_child_page(template_page: nil, position: nil, markdown: nil)
|
|
67
|
+
page = Page.new assign: [TitleProperty, "title"], parent: {"type" => "page_id", "page_id" => @id},
|
|
68
|
+
template_page: template_page, position: position, markdown: markdown
|
|
69
|
+
pp = page.properties
|
|
70
|
+
pp.clear_will_update
|
|
71
|
+
yield page, pp if block_given?
|
|
72
|
+
page
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# @param [Boolean] dry_run true if dry_run
|
|
76
|
+
# @return [NotionRubyMapping::Base]
|
|
77
|
+
# @param [String, NilClass] template_page
|
|
78
|
+
# @param [String, NilClass] position
|
|
79
|
+
# @param [String, NilClass] markdown
|
|
80
|
+
def create_child_page(template_page: nil, position: nil, markdown: nil, dry_run: false)
|
|
81
|
+
page = Page.new assign: [TitleProperty, "title"], parent: {"type" => "page_id", "page_id" => @id},
|
|
82
|
+
template_page: template_page, position: position, markdown: markdown
|
|
83
|
+
pp = page.properties
|
|
84
|
+
pp.clear_will_update
|
|
85
|
+
yield page, pp if block_given?
|
|
86
|
+
page.save dry_run: dry_run
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# @param [String] markdown
|
|
90
|
+
# @param [String, NilClass] after
|
|
91
|
+
# @param [Boolean] dry_run
|
|
92
|
+
# @return [String, NotionRubyMapping::Base]
|
|
93
|
+
def insert_markdown(markdown, after: nil, dry_run: false)
|
|
94
|
+
json = {"type" => "insert_content", "insert_content" => {"content" => markdown}}
|
|
95
|
+
json["insert_content"]["after"] = after if after
|
|
96
|
+
if dry_run
|
|
97
|
+
self.class.dry_run_script :patch, @nc.markdown_page_path(@id), json
|
|
98
|
+
else
|
|
99
|
+
update_json @nc.markdown_page_request(@id, json)
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
# @param [Page, DataSource] page_or_data_source
|
|
104
|
+
# @param [Boolean] dry_run true if dry_run
|
|
105
|
+
# @return [NotionRubyMapping::Page, String]
|
|
106
|
+
def move_to(page_or_data_source, dry_run: false)
|
|
107
|
+
key = page_or_data_source.is_a?(Page) ? "page_id" : "data_source_id"
|
|
108
|
+
json = {"parent" => {"type" => key, key => page_or_data_source.id}}
|
|
109
|
+
if dry_run
|
|
110
|
+
self.class.dry_run_script :post, @nc.move_page_path(@id), json
|
|
111
|
+
else
|
|
112
|
+
update_json @nc.move_page_request(@id, json)
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
62
116
|
# @return [String] 公開URL
|
|
63
117
|
def public_url
|
|
64
118
|
@json["public_url"]
|
|
65
119
|
end
|
|
66
120
|
|
|
121
|
+
# @param [String] replace
|
|
122
|
+
# @param [String] replace_range
|
|
123
|
+
# @param [Boolean] dry_run
|
|
124
|
+
# @return [String, NotionRubyMapping::Base]
|
|
125
|
+
def replace_markdown(replace, replace_range, allow_deleting_content: nil, dry_run: false)
|
|
126
|
+
json = {"type" => "replace_content_range",
|
|
127
|
+
"replace_content_range" => {"content" => replace, "content_range" => replace_range}}
|
|
128
|
+
json["replace_content_range"]["allow_deleting_content"] = true if allow_deleting_content
|
|
129
|
+
if dry_run
|
|
130
|
+
self.class.dry_run_script :patch, @nc.markdown_page_path(@id), json
|
|
131
|
+
else
|
|
132
|
+
update_json @nc.markdown_page_request(@id, json)
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
|
|
67
136
|
# @return [String] title
|
|
68
137
|
# @see https://www.notion.so/hkob/Page-d359650e3ca94424af8359a24147b9a0#2ff7209055f346fbbda454cdbb40b1c8
|
|
69
138
|
def title
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module NotionRubyMapping
|
|
4
|
+
# Notion block
|
|
5
|
+
class ToggleHeading4Block < TextSubBlockColorBaseBlock
|
|
6
|
+
# @return [String]
|
|
7
|
+
def type
|
|
8
|
+
"heading_4"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# @param [Boolean] not_update false when update
|
|
12
|
+
# @return [Hash{String (frozen)->Hash}]
|
|
13
|
+
def block_json(not_update: true)
|
|
14
|
+
ans = super
|
|
15
|
+
ans[type]["is_toggleable"] = true
|
|
16
|
+
ans
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -243,6 +243,51 @@ module NotionRubyMapping
|
|
|
243
243
|
"NotionCache"
|
|
244
244
|
end
|
|
245
245
|
|
|
246
|
+
# @param [String] data_source_id
|
|
247
|
+
# @param [Integer] page_size
|
|
248
|
+
# @param [String] start_cursor
|
|
249
|
+
# @return [Hash] response hash
|
|
250
|
+
def list_data_source_templates_request(data_source_id, page_size: nil, start_cursor: nil)
|
|
251
|
+
options = []
|
|
252
|
+
options << "page_size=#{page_size}" if page_size
|
|
253
|
+
options << "start_cursor=#{start_cursor}" if start_cursor
|
|
254
|
+
option_str = options.empty? ? "" : "?" + options.join("&")
|
|
255
|
+
request :get, list_data_source_templates_path(data_source_id, option_str)
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
# @param [String] data_source_id
|
|
259
|
+
# @param [String] options
|
|
260
|
+
# @return [String] path
|
|
261
|
+
def list_data_source_templates_path(data_source_id, options = "")
|
|
262
|
+
"v1/data_sources/#{data_source_id}/templates#{options}"
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
# @param [String] page_id
|
|
266
|
+
# @return [String] path
|
|
267
|
+
def markdown_page_path(page_id)
|
|
268
|
+
"v1/pages/#{page_id}/markdown"
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
# @param [String] page_id
|
|
272
|
+
# @param [Hash] payload
|
|
273
|
+
# @return [Hash] response hash
|
|
274
|
+
def markdown_page_request(page_id, payload)
|
|
275
|
+
request :patch, markdown_page_path(page_id), payload
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
# @param [String] page_id
|
|
279
|
+
# @param [Hash] payload
|
|
280
|
+
# @return [Hash] response hash
|
|
281
|
+
def move_page_request(page_id, payload)
|
|
282
|
+
request :post, move_page_path(page_id), payload
|
|
283
|
+
end
|
|
284
|
+
|
|
285
|
+
# @param [String] page_id
|
|
286
|
+
# @return [String] move_page_path
|
|
287
|
+
def move_page_path(page_id)
|
|
288
|
+
"v1/pages/#{page_id}/move"
|
|
289
|
+
end
|
|
290
|
+
|
|
246
291
|
# @param [String] path
|
|
247
292
|
# @param [String] fname
|
|
248
293
|
# @param [Hash] options
|
|
@@ -427,7 +472,7 @@ module NotionRubyMapping
|
|
|
427
472
|
request :get, user_path(user_id)
|
|
428
473
|
end
|
|
429
474
|
|
|
430
|
-
# @return [
|
|
475
|
+
# @return [NotionRubyMapping::ListObject] List Object for UserObject
|
|
431
476
|
def users
|
|
432
477
|
List.new json: users_request, type: "user_object", value: true
|
|
433
478
|
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module NotionRubyMapping
|
|
2
|
+
class TemplateObject
|
|
3
|
+
def initialize(json: json)
|
|
4
|
+
@id = json["id"]
|
|
5
|
+
@name = json["name"]
|
|
6
|
+
@is_default = json["is_default"]
|
|
7
|
+
end
|
|
8
|
+
attr_reader :id, :name, :is_default
|
|
9
|
+
|
|
10
|
+
# @return [Hash{String->String, Boolean}]
|
|
11
|
+
def property_values_json
|
|
12
|
+
{
|
|
13
|
+
"id" => @id,
|
|
14
|
+
"name" => @name,
|
|
15
|
+
"is_default" => @is_default
|
|
16
|
+
}
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -157,7 +157,7 @@ module NotionRubyMapping
|
|
|
157
157
|
!instance_of? Property
|
|
158
158
|
end
|
|
159
159
|
|
|
160
|
-
# @param [
|
|
160
|
+
# @param [String] key query parameter
|
|
161
161
|
# @param [Object] value query value
|
|
162
162
|
# @return [NotionRubyMapping::Query] generated Query object
|
|
163
163
|
def make_filter_query(key, value, condition: nil, another_type: nil)
|
|
@@ -30,6 +30,17 @@ module NotionRubyMapping
|
|
|
30
30
|
@json = json
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
+
## DataSource only methods
|
|
34
|
+
|
|
35
|
+
# @param [String, Number] value Query value
|
|
36
|
+
# @param [String] condition rollup Rollup name
|
|
37
|
+
# @param [String] another_type rollup_type Rollup type
|
|
38
|
+
# @return [NotionRubyMapping::Query] generated Query object
|
|
39
|
+
# @see https://www.notion.so/hkob/CheckboxProperty-ac1edbdb8e264af5ad1432b522b429fd#5f07c4ebc4744986bfc99a43827349fc
|
|
40
|
+
def filter_status(value, condition: nil, another_type: nil)
|
|
41
|
+
make_filter_query "status", value, condition: condition, another_type: another_type
|
|
42
|
+
end
|
|
43
|
+
|
|
33
44
|
## Page property only methods
|
|
34
45
|
|
|
35
46
|
# @return [Hash]
|
data/lib/notion_ruby_mapping.rb
CHANGED
|
@@ -11,11 +11,11 @@ require_relative "notion_ruby_mapping/version"
|
|
|
11
11
|
image_block toggle_heading1_block toggle_heading2_block toggle_heading3_block url_base_block
|
|
12
12
|
link_preview_block link_to_page_block numbered_list_item_block paragraph_block pdf_block quote_block
|
|
13
13
|
synced_block table_block table_row_block table_of_contents_block to_do_block
|
|
14
|
-
toggle_block video_block audio_block],
|
|
14
|
+
toggle_block video_block audio_block heading4_block toggle_heading4_block],
|
|
15
15
|
controllers: %w[notion_cache payload property_cache query rich_text_array discussion_thread search mermaid
|
|
16
16
|
mermaid_data_source],
|
|
17
17
|
objects: %w[rich_text_object emoji_object equation_object file_object mention_object text_object user_object
|
|
18
|
-
comment_object file_upload_object],
|
|
18
|
+
comment_object file_upload_object template_object],
|
|
19
19
|
properties: %w[property checkbox_property multi_property created_by_property date_base_property created_time_property
|
|
20
20
|
date_property email_property files_property formula_property last_edited_by_property
|
|
21
21
|
last_edited_time_property multi_select_property number_property people_property phone_number_property
|
data/notion_ruby_mapping.gemspec
CHANGED
|
@@ -38,6 +38,9 @@ Gem::Specification.new do |spec|
|
|
|
38
38
|
spec.add_dependency "faraday-multipart"
|
|
39
39
|
spec.add_dependency "mime-types"
|
|
40
40
|
|
|
41
|
+
spec.add_development_dependency "pry"
|
|
42
|
+
spec.add_development_dependency "pry-byebug"
|
|
43
|
+
spec.add_development_dependency "rb-readline"
|
|
41
44
|
spec.add_development_dependency "guard"
|
|
42
45
|
spec.add_development_dependency "guard-rspec"
|
|
43
46
|
spec.add_development_dependency "rake"
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: notion_ruby_mapping
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 4.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Hiroyuki KOBAYASHI
|
|
@@ -51,6 +51,48 @@ dependencies:
|
|
|
51
51
|
- - ">="
|
|
52
52
|
- !ruby/object:Gem::Version
|
|
53
53
|
version: '0'
|
|
54
|
+
- !ruby/object:Gem::Dependency
|
|
55
|
+
name: pry
|
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - ">="
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: '0'
|
|
61
|
+
type: :development
|
|
62
|
+
prerelease: false
|
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - ">="
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: '0'
|
|
68
|
+
- !ruby/object:Gem::Dependency
|
|
69
|
+
name: pry-byebug
|
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
|
71
|
+
requirements:
|
|
72
|
+
- - ">="
|
|
73
|
+
- !ruby/object:Gem::Version
|
|
74
|
+
version: '0'
|
|
75
|
+
type: :development
|
|
76
|
+
prerelease: false
|
|
77
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
78
|
+
requirements:
|
|
79
|
+
- - ">="
|
|
80
|
+
- !ruby/object:Gem::Version
|
|
81
|
+
version: '0'
|
|
82
|
+
- !ruby/object:Gem::Dependency
|
|
83
|
+
name: rb-readline
|
|
84
|
+
requirement: !ruby/object:Gem::Requirement
|
|
85
|
+
requirements:
|
|
86
|
+
- - ">="
|
|
87
|
+
- !ruby/object:Gem::Version
|
|
88
|
+
version: '0'
|
|
89
|
+
type: :development
|
|
90
|
+
prerelease: false
|
|
91
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
92
|
+
requirements:
|
|
93
|
+
- - ">="
|
|
94
|
+
- !ruby/object:Gem::Version
|
|
95
|
+
version: '0'
|
|
54
96
|
- !ruby/object:Gem::Dependency
|
|
55
97
|
name: guard
|
|
56
98
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -200,6 +242,7 @@ files:
|
|
|
200
242
|
- lib/notion_ruby_mapping/blocks/heading1_block.rb
|
|
201
243
|
- lib/notion_ruby_mapping/blocks/heading2_block.rb
|
|
202
244
|
- lib/notion_ruby_mapping/blocks/heading3_block.rb
|
|
245
|
+
- lib/notion_ruby_mapping/blocks/heading4_block.rb
|
|
203
246
|
- lib/notion_ruby_mapping/blocks/image_block.rb
|
|
204
247
|
- lib/notion_ruby_mapping/blocks/link_preview_block.rb
|
|
205
248
|
- lib/notion_ruby_mapping/blocks/link_to_page_block.rb
|
|
@@ -219,6 +262,7 @@ files:
|
|
|
219
262
|
- lib/notion_ruby_mapping/blocks/toggle_heading1_block.rb
|
|
220
263
|
- lib/notion_ruby_mapping/blocks/toggle_heading2_block.rb
|
|
221
264
|
- lib/notion_ruby_mapping/blocks/toggle_heading3_block.rb
|
|
265
|
+
- lib/notion_ruby_mapping/blocks/toggle_heading4_block.rb
|
|
222
266
|
- lib/notion_ruby_mapping/blocks/url_base_block.rb
|
|
223
267
|
- lib/notion_ruby_mapping/blocks/url_caption_base_block.rb
|
|
224
268
|
- lib/notion_ruby_mapping/blocks/video_block.rb
|
|
@@ -238,6 +282,7 @@ files:
|
|
|
238
282
|
- lib/notion_ruby_mapping/objects/file_upload_object.rb
|
|
239
283
|
- lib/notion_ruby_mapping/objects/mention_object.rb
|
|
240
284
|
- lib/notion_ruby_mapping/objects/rich_text_object.rb
|
|
285
|
+
- lib/notion_ruby_mapping/objects/template_object.rb
|
|
241
286
|
- lib/notion_ruby_mapping/objects/text_object.rb
|
|
242
287
|
- lib/notion_ruby_mapping/objects/user_object.rb
|
|
243
288
|
- lib/notion_ruby_mapping/properties/button_property.rb
|
|
@@ -289,7 +334,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
289
334
|
- !ruby/object:Gem::Version
|
|
290
335
|
version: '0'
|
|
291
336
|
requirements: []
|
|
292
|
-
rubygems_version: 4.0.
|
|
337
|
+
rubygems_version: 4.0.6
|
|
293
338
|
specification_version: 4
|
|
294
339
|
summary: Notion Ruby mapping tool
|
|
295
340
|
test_files: []
|