notion_ruby_mapping 0.6.6 → 0.6.8
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 +2 -0
- data/lib/notion_ruby_mapping/blocks/base.rb +8 -6
- data/lib/notion_ruby_mapping/blocks/block.rb +3 -1
- data/lib/notion_ruby_mapping/blocks/database.rb +6 -1
- data/lib/notion_ruby_mapping/blocks/heading1_block.rb +8 -0
- data/lib/notion_ruby_mapping/blocks/heading2_block.rb +8 -0
- data/lib/notion_ruby_mapping/blocks/heading3_block.rb +8 -0
- data/lib/notion_ruby_mapping/blocks/list.rb +19 -5
- data/lib/notion_ruby_mapping/blocks/page.rb +7 -2
- data/lib/notion_ruby_mapping/blocks/toggle_heading1_block.rb +8 -0
- data/lib/notion_ruby_mapping/blocks/toggle_heading2_block.rb +8 -0
- data/lib/notion_ruby_mapping/blocks/toggle_heading3_block.rb +8 -0
- data/lib/notion_ruby_mapping/controllers/discussion_thread.rb +1 -1
- data/lib/notion_ruby_mapping/controllers/notion_cache.rb +35 -0
- data/lib/notion_ruby_mapping/controllers/property_cache.rb +4 -0
- data/lib/notion_ruby_mapping/objects/comment_object.rb +1 -1
- data/lib/notion_ruby_mapping/objects/user_object.rb +35 -3
- data/lib/notion_ruby_mapping/properties/checkbox_property.rb +4 -3
- data/lib/notion_ruby_mapping/properties/created_by_property.rb +4 -2
- data/lib/notion_ruby_mapping/properties/created_time_property.rb +3 -2
- data/lib/notion_ruby_mapping/properties/date_base_property.rb +59 -57
- data/lib/notion_ruby_mapping/properties/date_property.rb +8 -6
- data/lib/notion_ruby_mapping/properties/email_property.rb +3 -2
- data/lib/notion_ruby_mapping/properties/files_property.rb +4 -2
- data/lib/notion_ruby_mapping/properties/formula_property.rb +4 -2
- data/lib/notion_ruby_mapping/properties/last_edited_by_property.rb +4 -2
- data/lib/notion_ruby_mapping/properties/last_edited_time_property.rb +3 -2
- data/lib/notion_ruby_mapping/properties/multi_select_property.rb +4 -2
- data/lib/notion_ruby_mapping/properties/number_property.rb +5 -3
- data/lib/notion_ruby_mapping/properties/people_property.rb +11 -3
- data/lib/notion_ruby_mapping/properties/phone_number_property.rb +3 -2
- data/lib/notion_ruby_mapping/properties/property.rb +44 -36
- data/lib/notion_ruby_mapping/properties/relation_property.rb +6 -6
- data/lib/notion_ruby_mapping/properties/rollup_property.rb +4 -2
- data/lib/notion_ruby_mapping/properties/select_property.rb +4 -2
- data/lib/notion_ruby_mapping/properties/status_property.rb +26 -4
- data/lib/notion_ruby_mapping/properties/text_property.rb +4 -2
- data/lib/notion_ruby_mapping/properties/title_property.rb +6 -2
- data/lib/notion_ruby_mapping/properties/url_property.rb +3 -2
- data/lib/notion_ruby_mapping/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1372e3b57aef4a44d060751e07ba15bd224d23b974ff46426ac4e40a10c0b0b6
|
4
|
+
data.tar.gz: b6310155b12dcb73f022bd9415667c67b8a78246377622128fb0bcd2eccb4bd9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01a32f40c022b5916891409b823bf76efd02414520e14eb98dc1f7ec49901fcc60fd085c845fe71f0b38a5d3776e32a6c9bce4e5c2efb5edce750f2b24a66ff8
|
7
|
+
data.tar.gz: 06babf96d0c07ccc74c2ab24ccf55500ed8c75506c2e5c0c95837968795af8192eea3e773ca153254048a63204ed6fed4996a1a25f74ced78187d52114c4ca4a
|
data/README.md
CHANGED
@@ -92,6 +92,8 @@ NotionCache.instance.create_client ENV["NOTION_API_TOKEN"] # from environment
|
|
92
92
|
|
93
93
|
## 3. ChangeLog
|
94
94
|
|
95
|
+
- 2022/11/13 [v0.6.8] remove error checking for start and end dates, add Users.all, and change Rollup and Formula query specification
|
96
|
+
- 2022/9/2 [v0.6.7] add support for Status property, is_toggleable for headings block, and page property values
|
95
97
|
- 2022/8/10 [v0.6.6] Bug fix(notionSitemap.rb): Skip if child page is empty.
|
96
98
|
- 2022/8/10 [v0.6.5] add notionSitemap.rb, rename createErDiagram to notionErDiagram, and move them to exe directory
|
97
99
|
- 2022/8/9 [v0.6.4] url can be entered instead of page_id, block_id and database_id
|
@@ -60,7 +60,7 @@ module NotionRubyMapping
|
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
|
-
# @param [
|
63
|
+
# @param [Symbol] method
|
64
64
|
# @param [Object] path
|
65
65
|
# @param [nil] json
|
66
66
|
def self.dry_run_script(method, path, json = nil)
|
@@ -82,6 +82,7 @@ module NotionRubyMapping
|
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
85
|
+
# @param [Boolean] dry_run true if dry_run
|
85
86
|
def comments(query = nil, dry_run: false)
|
86
87
|
return unless page? || block?
|
87
88
|
|
@@ -89,7 +90,7 @@ module NotionRubyMapping
|
|
89
90
|
self.class.dry_run_script :get, @nc.retrieve_comments_path(@id)
|
90
91
|
else
|
91
92
|
ans = {}
|
92
|
-
List.new(comment_parent: self,
|
93
|
+
List.new(type: :comment_parent, value: self,
|
93
94
|
json: @nc.retrieve_comments_request(@id, query),
|
94
95
|
query: query).each do |comment|
|
95
96
|
dt_id = comment.discussion_id
|
@@ -117,7 +118,7 @@ module NotionRubyMapping
|
|
117
118
|
end
|
118
119
|
|
119
120
|
# @param [Array<Block>] blocks
|
120
|
-
# @param [Boolean] dry_run
|
121
|
+
# @param [Boolean] dry_run true if dry_run
|
121
122
|
# @return [NotionRubyMapping::Block, String]
|
122
123
|
# @see https://www.notion.so/hkob/Page-d359650e3ca94424af8359a24147b9a0#44bbf83d852c419485c5efe9fe1558fb
|
123
124
|
# @see https://www.notion.so/hkob/Block-689ad4cbff50404d8a1baf67b6d6d78d#2c47f7fedae543cf8566389ba1677132
|
@@ -180,7 +181,7 @@ module NotionRubyMapping
|
|
180
181
|
end
|
181
182
|
|
182
183
|
# @param [NotionRubyMapping::Query] query
|
183
|
-
# @param [Boolean] dry_run
|
184
|
+
# @param [Boolean] dry_run true if dry_run
|
184
185
|
# @return [NotionRubyMapping::List, String]
|
185
186
|
def children(query = Query.new, dry_run: false)
|
186
187
|
if dry_run
|
@@ -190,7 +191,7 @@ module NotionRubyMapping
|
|
190
191
|
@children
|
191
192
|
else
|
192
193
|
response = @nc.block_children_request @id, query.query_string
|
193
|
-
@children = List.new json: response, parent: self, query: query
|
194
|
+
@children = List.new json: response, type: :parent, value: self, query: query
|
194
195
|
end
|
195
196
|
end
|
196
197
|
|
@@ -236,6 +237,7 @@ module NotionRubyMapping
|
|
236
237
|
is_a? Page
|
237
238
|
end
|
238
239
|
|
240
|
+
# @param [Boolean] dry_run true if dry_run
|
239
241
|
def parent(dry_run: false)
|
240
242
|
parent_json = @json && @json["parent"]
|
241
243
|
raise StandardError, "Unknown parent" if parent_json.nil?
|
@@ -298,7 +300,7 @@ module NotionRubyMapping
|
|
298
300
|
self
|
299
301
|
end
|
300
302
|
|
301
|
-
# @param [Boolean] dry_run
|
303
|
+
# @param [Boolean] dry_run true if dry_run
|
302
304
|
# @return [NotionRubyMapping::Base, NotionRubyMapping::Database, String]
|
303
305
|
# @see https://www.notion.so/hkob/Page-d359650e3ca94424af8359a24147b9a0#277085c8439841c798a4b94eae9a7326
|
304
306
|
def save(dry_run: false)
|
@@ -64,6 +64,7 @@ module NotionRubyMapping
|
|
64
64
|
|
65
65
|
# @see https://www.notion.so/hkob/Block-689ad4cbff50404d8a1baf67b6d6d78d#298916c7c379424682f39ff09ee38544
|
66
66
|
# @param [String] id
|
67
|
+
# @param [Boolean] dry_run true if dry_run
|
67
68
|
# @return [NotionRubyMapping::Block]
|
68
69
|
def self.find(id, dry_run: false)
|
69
70
|
nc = NotionCache.instance
|
@@ -104,7 +105,7 @@ module NotionRubyMapping
|
|
104
105
|
@rich_text_array = RichTextArray.new "rich_text", json: @json[type]["rich_text"]
|
105
106
|
end
|
106
107
|
|
107
|
-
# @param [Boolean] dry_run
|
108
|
+
# @param [Boolean] dry_run true if dry_run
|
108
109
|
# @return [NotionRubyMapping::Base, String]
|
109
110
|
def destroy(dry_run: false)
|
110
111
|
if dry_run
|
@@ -114,6 +115,7 @@ module NotionRubyMapping
|
|
114
115
|
end
|
115
116
|
end
|
116
117
|
|
118
|
+
# @param [Boolean] dry_run true if dry_run
|
117
119
|
# @return [NotionRubyMapping::Base, String]
|
118
120
|
def update(dry_run: false)
|
119
121
|
if dry_run
|
@@ -6,6 +6,7 @@ module NotionRubyMapping
|
|
6
6
|
### Public announced methods
|
7
7
|
|
8
8
|
# @param [String] id
|
9
|
+
# @param [Boolean] dry_run true if dry_run
|
9
10
|
# @return [NotionRubyMapping::Database, String]
|
10
11
|
# @see https://www.notion.so/hkob/Database-1462b24502424539a4231bedc07dc2f5#58ba9190fd544432a9e2a5823d6c33b7
|
11
12
|
def self.find(id, dry_run: false)
|
@@ -49,6 +50,7 @@ module NotionRubyMapping
|
|
49
50
|
end
|
50
51
|
|
51
52
|
# @param [Array<Property, Class, String>] assign
|
53
|
+
# @param [Boolean] dry_run true if dry_run
|
52
54
|
# @return [NotionRubyMapping::Base]
|
53
55
|
# @see https://www.notion.so/hkob/Database-1462b24502424539a4231bedc07dc2f5#c217ce78020a4de79b720790fce3092d
|
54
56
|
def create_child_page(*assign, dry_run: false)
|
@@ -97,6 +99,7 @@ module NotionRubyMapping
|
|
97
99
|
end
|
98
100
|
|
99
101
|
# @param [NotionRubyMapping::Query] query object
|
102
|
+
# @param [Boolean] dry_run true if dry_run
|
100
103
|
# @return [NotionRubyMapping::List, String]
|
101
104
|
# @see https://www.notion.so/hkob/Database-1462b24502424539a4231bedc07dc2f5#6bd9acf62c454f64bc555c8828057e6b
|
102
105
|
def query_database(query = Query.new, dry_run: false)
|
@@ -104,7 +107,7 @@ module NotionRubyMapping
|
|
104
107
|
Base.dry_run_script :post, @nc.query_database_path(@id), query.query_json
|
105
108
|
else
|
106
109
|
response = @nc.database_query_request @id, query
|
107
|
-
List.new json: response, database: self, query: query
|
110
|
+
List.new json: response, type: :database, value: self, query: query
|
108
111
|
end
|
109
112
|
end
|
110
113
|
|
@@ -130,6 +133,7 @@ module NotionRubyMapping
|
|
130
133
|
|
131
134
|
protected
|
132
135
|
|
136
|
+
# @param [Boolean] dry_run true if dry_run
|
133
137
|
def create(dry_run: false)
|
134
138
|
if dry_run
|
135
139
|
dry_run_script :post, @nc.databases_path, :property_schema_json
|
@@ -145,6 +149,7 @@ module NotionRubyMapping
|
|
145
149
|
@nc.database_request @id
|
146
150
|
end
|
147
151
|
|
152
|
+
# @param [Boolean] dry_run true if dry_run
|
148
153
|
# @return [NotionRubyMapping::Base, String]
|
149
154
|
def update(dry_run: false)
|
150
155
|
if dry_run
|
@@ -14,5 +14,13 @@ module NotionRubyMapping
|
|
14
14
|
def type
|
15
15
|
"heading_1"
|
16
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
|
17
25
|
end
|
18
26
|
end
|
@@ -14,5 +14,13 @@ module NotionRubyMapping
|
|
14
14
|
def type
|
15
15
|
"heading_2"
|
16
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
|
17
25
|
end
|
18
26
|
end
|
@@ -14,5 +14,13 @@ module NotionRubyMapping
|
|
14
14
|
def type
|
15
15
|
"heading_3"
|
16
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
|
17
25
|
end
|
18
26
|
end
|
@@ -5,14 +5,23 @@ module NotionRubyMapping
|
|
5
5
|
class List < Base
|
6
6
|
include Enumerable
|
7
7
|
|
8
|
-
def initialize(json: nil, id: nil,
|
8
|
+
def initialize(json: nil, id: nil, type: nil, value: nil, query: nil)
|
9
9
|
super(json: json, id: id)
|
10
10
|
@has_more = @json["has_more"]
|
11
11
|
@load_all_contents = !@has_more
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
|
13
|
+
case type
|
14
|
+
when :comment_parent
|
15
|
+
@comment_parent = value
|
16
|
+
when :database
|
17
|
+
@database = value
|
18
|
+
when :parent
|
19
|
+
@parent = value
|
20
|
+
when :property
|
21
|
+
@property = value
|
22
|
+
when :user_object
|
23
|
+
@user_object = true
|
24
|
+
end
|
16
25
|
@query = query
|
17
26
|
@index = 0
|
18
27
|
@has_content = true
|
@@ -60,6 +69,11 @@ module NotionRubyMapping
|
|
60
69
|
query: -> { @nc.retrieve_comments_request @comment_parent.id, @query },
|
61
70
|
create_object: ->(json) { CommentObject.new json: json },
|
62
71
|
&block
|
72
|
+
elsif @user_object
|
73
|
+
each_sub base: @user_object,
|
74
|
+
query: -> { @nc.users_request @query.query_json },
|
75
|
+
create_object: ->(json) { UserObject.new json: json },
|
76
|
+
&block
|
63
77
|
end
|
64
78
|
self
|
65
79
|
end
|
@@ -6,6 +6,7 @@ module NotionRubyMapping
|
|
6
6
|
### Public announced methods
|
7
7
|
|
8
8
|
# @param [String] id
|
9
|
+
# @param [Boolean] dry_run true if dry_run
|
9
10
|
# @return [NotionRubyMapping::Page, String]
|
10
11
|
# @see https://www.notion.so/hkob/Page-d359650e3ca94424af8359a24147b9a0#7d868b8b81c3473082bbdc7370813a4a
|
11
12
|
def self.find(id, dry_run: false)
|
@@ -24,6 +25,7 @@ module NotionRubyMapping
|
|
24
25
|
get key
|
25
26
|
end
|
26
27
|
|
28
|
+
# @param [Boolean] dry_run true if dry_run
|
27
29
|
def append_comment(text_objects, dry_run: false)
|
28
30
|
rto = RichTextArray.new "rich_text", text_objects: text_objects, will_update: true
|
29
31
|
json = rto.property_schema_json.merge({"parent" => {"page_id" => @id}})
|
@@ -47,7 +49,8 @@ module NotionRubyMapping
|
|
47
49
|
|
48
50
|
# @param [String] title
|
49
51
|
# @param [Array<String, Property>] assigns
|
50
|
-
# @
|
52
|
+
# @param [Boolean] dry_run true if dry_run
|
53
|
+
# @return [NotionRubyMapping::Database, String]
|
51
54
|
# @see https://www.notion.so/hkob/Page-d359650e3ca94424af8359a24147b9a0#e3f1d21e0f724f589e48431468772eed
|
52
55
|
def create_child_database(title, *assigns, dry_run: false)
|
53
56
|
build_child_database(title, *assigns).save dry_run: dry_run
|
@@ -56,12 +59,13 @@ module NotionRubyMapping
|
|
56
59
|
# @return [String] title
|
57
60
|
# @see https://www.notion.so/hkob/Page-d359650e3ca94424af8359a24147b9a0#2ff7209055f346fbbda454cdbb40b1c8
|
58
61
|
def title
|
59
|
-
tp = properties.select { |p|
|
62
|
+
tp = properties.select { |p| p.is_a?(TitleProperty) || (p.is_a?(Property) && p.property_id == "title") }
|
60
63
|
tp.map(&:full_text).join ""
|
61
64
|
end
|
62
65
|
|
63
66
|
protected
|
64
67
|
|
68
|
+
# @param [Boolean] dry_run true if dry_run
|
65
69
|
# @return [NotionRubyMapping::Base, String]
|
66
70
|
def create(dry_run: false)
|
67
71
|
if dry_run
|
@@ -77,6 +81,7 @@ module NotionRubyMapping
|
|
77
81
|
@nc.page_request @id
|
78
82
|
end
|
79
83
|
|
84
|
+
# @param [Boolean] dry_run true if dry_run
|
80
85
|
# @return [NotionRubyMapping::Base, String]
|
81
86
|
def update(dry_run: false)
|
82
87
|
if dry_run
|
@@ -7,5 +7,13 @@ module NotionRubyMapping
|
|
7
7
|
def type
|
8
8
|
"heading_1"
|
9
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
|
10
18
|
end
|
11
19
|
end
|
@@ -7,5 +7,13 @@ module NotionRubyMapping
|
|
7
7
|
def type
|
8
8
|
"heading_2"
|
9
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
|
10
18
|
end
|
11
19
|
end
|
@@ -7,5 +7,13 @@ module NotionRubyMapping
|
|
7
7
|
def type
|
8
8
|
"heading_3"
|
9
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
|
10
18
|
end
|
11
19
|
end
|
@@ -11,7 +11,7 @@ module NotionRubyMapping
|
|
11
11
|
attr_reader :discussion_id, :comments
|
12
12
|
|
13
13
|
# @param [String] text_objects
|
14
|
-
# @param [Boolean] dry_run
|
14
|
+
# @param [Boolean] dry_run true if dry_run
|
15
15
|
# @return [String, NotionRubyMapping::CommentObject]
|
16
16
|
def append_comment(text_objects, dry_run: false)
|
17
17
|
rto = RichTextArray.new "rich_text", text_objects: text_objects, will_update: true
|
@@ -284,5 +284,40 @@ module NotionRubyMapping
|
|
284
284
|
def update_page_request(page_id, payload)
|
285
285
|
request :patch, page_path(page_id), payload
|
286
286
|
end
|
287
|
+
|
288
|
+
# @param [String] id user_id (with or without "-")
|
289
|
+
# @return [NotionRubyMapping::UserObject] UserObject object or nil
|
290
|
+
def user(id)
|
291
|
+
UserObject.new json: user_request(id)
|
292
|
+
end
|
293
|
+
|
294
|
+
# @param [String] user_id
|
295
|
+
# @return [String (frozen)] user_path
|
296
|
+
def user_path(user_id)
|
297
|
+
"v1/users/#{user_id}"
|
298
|
+
end
|
299
|
+
|
300
|
+
# @param [String] user_id
|
301
|
+
# @return [Hash] response
|
302
|
+
def user_request(user_id)
|
303
|
+
request :get, user_path(user_id)
|
304
|
+
end
|
305
|
+
|
306
|
+
# @return [Array<NotionRubyMapping::UserObject>] UserObject array
|
307
|
+
def users
|
308
|
+
List.new json: users_request, type: :user_object, value: true
|
309
|
+
end
|
310
|
+
|
311
|
+
# @return [String (frozen)] user_path
|
312
|
+
def users_path(option = "")
|
313
|
+
"v1/users#{option}"
|
314
|
+
end
|
315
|
+
|
316
|
+
# @param [String] user_id
|
317
|
+
# @param [NotionRubyMapping::Query] query query object
|
318
|
+
# @return [Hash] response
|
319
|
+
def users_request(query = Query.new)
|
320
|
+
request :get, users_path, query.query_json
|
321
|
+
end
|
287
322
|
end
|
288
323
|
end
|
@@ -6,11 +6,38 @@ module NotionRubyMapping
|
|
6
6
|
# @param [String] user_id
|
7
7
|
# @return [TextObject]
|
8
8
|
def initialize(user_id: nil, json: {})
|
9
|
-
@user_id = user_id || json && json["id"]
|
9
|
+
@user_id = NotionCache.instance.hex_id(user_id || json && json["id"])
|
10
10
|
@json = json
|
11
11
|
@will_update = false
|
12
12
|
end
|
13
|
-
attr_reader :will_update, :user_id
|
13
|
+
attr_reader :will_update, :user_id, :json
|
14
|
+
|
15
|
+
# @param [Boolean] dry_run true if dry_run
|
16
|
+
def self.all(dry_run: false)
|
17
|
+
nc = NotionCache.instance
|
18
|
+
if dry_run
|
19
|
+
Base.dry_run_script :get, nc.users_path
|
20
|
+
else
|
21
|
+
nc.users
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# @param [String] user_id
|
26
|
+
# @param [Boolean] dry_run true if dry_run
|
27
|
+
# @return [NotionRubyMapping::UserObject, String]
|
28
|
+
def self.find(user_id, dry_run: false)
|
29
|
+
nc = NotionCache.instance
|
30
|
+
if dry_run
|
31
|
+
Base.dry_run_script :get, nc.user_path(user_id)
|
32
|
+
else
|
33
|
+
nc.user user_id
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# @param [Boolean] dry_run true if dry_run
|
38
|
+
def self.find_me(dry_run: false)
|
39
|
+
find "me", dry_run: dry_run
|
40
|
+
end
|
14
41
|
|
15
42
|
# @param [UserObject, String] uo
|
16
43
|
# @return [UserObject] self or created UserObject
|
@@ -22,6 +49,11 @@ module NotionRubyMapping
|
|
22
49
|
end
|
23
50
|
end
|
24
51
|
|
52
|
+
# @return [String (frozen)]
|
53
|
+
def inspect
|
54
|
+
"#{self.class.name}-#{@user_id}"
|
55
|
+
end
|
56
|
+
|
25
57
|
# @return [String]
|
26
58
|
def name
|
27
59
|
@json["name"]
|
@@ -36,7 +68,7 @@ module NotionRubyMapping
|
|
36
68
|
end
|
37
69
|
|
38
70
|
def user_id=(new_user_id)
|
39
|
-
@user_id = new_user_id
|
71
|
+
@user_id = NotionCache.instance.hex_id new_user_id
|
40
72
|
@will_update = true
|
41
73
|
end
|
42
74
|
end
|
@@ -10,7 +10,7 @@ module NotionRubyMapping
|
|
10
10
|
|
11
11
|
## Common methods
|
12
12
|
|
13
|
-
# @return [Boolean, Hash]
|
13
|
+
# @return [Boolean, Hash, nil]
|
14
14
|
# @see https://www.notion.so/hkob/CheckboxProperty-ac1edbdb8e264af5ad1432b522b429fd#20da1bf0cbcc4d4eb22d9125386522c2
|
15
15
|
def checkbox
|
16
16
|
@json
|
@@ -33,8 +33,9 @@ module NotionRubyMapping
|
|
33
33
|
|
34
34
|
# @param [String] name Property name
|
35
35
|
# @param [Boolean, Hash] json
|
36
|
-
def initialize(name, will_update: false, base_type: :page, property_cache: nil, json: nil)
|
37
|
-
super name, will_update: will_update, base_type: base_type,
|
36
|
+
def initialize(name, will_update: false, base_type: :page, property_id: nil, property_cache: nil, json: nil)
|
37
|
+
super name, will_update: will_update, base_type: base_type, property_id: property_id,
|
38
|
+
property_cache: property_cache
|
38
39
|
@json = if database?
|
39
40
|
json || {}
|
40
41
|
else
|
@@ -22,8 +22,10 @@ module NotionRubyMapping
|
|
22
22
|
# @param [String] name Property name
|
23
23
|
# @param [String] user_id user_id (optional)
|
24
24
|
# @param [Hash] json json (optional)
|
25
|
-
def initialize(name, will_update: false, base_type: :page, json: nil, user_id: nil,
|
26
|
-
|
25
|
+
def initialize(name, will_update: false, base_type: :page, json: nil, user_id: nil, property_id: nil,
|
26
|
+
property_cache: nil)
|
27
|
+
super name, will_update: will_update, base_type: base_type, property_id: property_id,
|
28
|
+
property_cache: property_cache
|
27
29
|
@json = if database?
|
28
30
|
json || {}
|
29
31
|
else
|
@@ -21,8 +21,9 @@ module NotionRubyMapping
|
|
21
21
|
|
22
22
|
# @param [String] name Property name
|
23
23
|
# @param [String] json created_time value (optional)
|
24
|
-
def initialize(name, will_update: false, base_type: :page, json: nil, property_cache: nil)
|
25
|
-
super name, will_update: will_update, base_type: base_type,
|
24
|
+
def initialize(name, will_update: false, base_type: :page, json: nil, property_id: nil, property_cache: nil)
|
25
|
+
super name, will_update: will_update, base_type: base_type, property_id: property_id,
|
26
|
+
property_cache: property_cache
|
26
27
|
@json = json
|
27
28
|
@json ||= {} if database?
|
28
29
|
end
|