notion_ruby_mapping 0.8.8 → 1.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/.rubocop.yml +12 -1
- data/README.md +1 -0
- data/lib/notion_ruby_mapping/blocks/base.rb +33 -33
- data/lib/notion_ruby_mapping/blocks/block.rb +48 -47
- data/lib/notion_ruby_mapping/blocks/bookmark_block.rb +1 -1
- data/lib/notion_ruby_mapping/blocks/breadcrumb_block.rb +1 -1
- data/lib/notion_ruby_mapping/blocks/bulleted_list_item_block.rb +1 -1
- data/lib/notion_ruby_mapping/blocks/callout_block.rb +10 -10
- data/lib/notion_ruby_mapping/blocks/child_base_block.rb +2 -2
- data/lib/notion_ruby_mapping/blocks/child_database_block.rb +3 -3
- data/lib/notion_ruby_mapping/blocks/child_page_block.rb +3 -3
- data/lib/notion_ruby_mapping/blocks/code_block.rb +7 -7
- data/lib/notion_ruby_mapping/blocks/column_block.rb +3 -3
- data/lib/notion_ruby_mapping/blocks/column_list_block.rb +2 -2
- data/lib/notion_ruby_mapping/blocks/database.rb +6 -6
- data/lib/notion_ruby_mapping/blocks/divider_block.rb +1 -1
- data/lib/notion_ruby_mapping/blocks/embed_block.rb +2 -2
- data/lib/notion_ruby_mapping/blocks/equation_block.rb +5 -5
- data/lib/notion_ruby_mapping/blocks/file_base_block.rb +2 -2
- data/lib/notion_ruby_mapping/blocks/file_block.rb +1 -1
- data/lib/notion_ruby_mapping/blocks/heading1_block.rb +4 -4
- data/lib/notion_ruby_mapping/blocks/heading2_block.rb +2 -2
- data/lib/notion_ruby_mapping/blocks/heading3_block.rb +3 -3
- data/lib/notion_ruby_mapping/blocks/image_block.rb +1 -1
- data/lib/notion_ruby_mapping/blocks/link_preview_block.rb +2 -2
- data/lib/notion_ruby_mapping/blocks/link_to_page_block.rb +5 -5
- data/lib/notion_ruby_mapping/blocks/list.rb +21 -20
- data/lib/notion_ruby_mapping/blocks/numbered_list_item_block.rb +2 -2
- data/lib/notion_ruby_mapping/blocks/page.rb +9 -10
- data/lib/notion_ruby_mapping/blocks/paragraph_block.rb +2 -2
- data/lib/notion_ruby_mapping/blocks/pdf_block.rb +2 -2
- data/lib/notion_ruby_mapping/blocks/quote_block.rb +1 -1
- data/lib/notion_ruby_mapping/blocks/synced_block.rb +5 -5
- data/lib/notion_ruby_mapping/blocks/table_block.rb +8 -8
- data/lib/notion_ruby_mapping/blocks/table_of_contents_block.rb +3 -3
- data/lib/notion_ruby_mapping/blocks/table_row_block.rb +3 -3
- data/lib/notion_ruby_mapping/blocks/template_block.rb +3 -3
- data/lib/notion_ruby_mapping/blocks/text_sub_block_color_base_block.rb +4 -4
- data/lib/notion_ruby_mapping/blocks/to_do_block.rb +4 -4
- data/lib/notion_ruby_mapping/blocks/toggle_block.rb +2 -2
- data/lib/notion_ruby_mapping/blocks/toggle_heading1_block.rb +2 -2
- data/lib/notion_ruby_mapping/blocks/toggle_heading2_block.rb +2 -2
- data/lib/notion_ruby_mapping/blocks/toggle_heading3_block.rb +3 -3
- data/lib/notion_ruby_mapping/blocks/url_base_block.rb +3 -3
- data/lib/notion_ruby_mapping/blocks/url_caption_base_block.rb +4 -4
- data/lib/notion_ruby_mapping/blocks/video_block.rb +2 -2
- data/lib/notion_ruby_mapping/controllers/discussion_thread.rb +1 -1
- data/lib/notion_ruby_mapping/controllers/mermaid_database.rb +34 -34
- data/lib/notion_ruby_mapping/controllers/notion_cache.rb +6 -8
- data/lib/notion_ruby_mapping/controllers/payload.rb +11 -11
- data/lib/notion_ruby_mapping/controllers/property_cache.rb +8 -7
- data/lib/notion_ruby_mapping/controllers/query.rb +10 -10
- data/lib/notion_ruby_mapping/controllers/search.rb +5 -6
- data/lib/notion_ruby_mapping/objects/comment_object.rb +2 -2
- data/lib/notion_ruby_mapping/objects/emoji_object.rb +3 -3
- data/lib/notion_ruby_mapping/objects/equation_object.rb +3 -3
- data/lib/notion_ruby_mapping/objects/file_object.rb +9 -9
- data/lib/notion_ruby_mapping/objects/mention_object.rb +43 -43
- data/lib/notion_ruby_mapping/objects/rich_text_object.rb +43 -43
- data/lib/notion_ruby_mapping/objects/text_object.rb +5 -5
- data/lib/notion_ruby_mapping/objects/user_object.rb +4 -4
- data/lib/notion_ruby_mapping/properties/button_property.rb +4 -4
- data/lib/notion_ruby_mapping/properties/checkbox_property.rb +3 -3
- data/lib/notion_ruby_mapping/properties/created_by_property.rb +3 -3
- data/lib/notion_ruby_mapping/properties/created_time_property.rb +2 -2
- data/lib/notion_ruby_mapping/properties/date_base_property.rb +14 -13
- data/lib/notion_ruby_mapping/properties/date_property.rb +17 -17
- data/lib/notion_ruby_mapping/properties/email_property.rb +3 -3
- data/lib/notion_ruby_mapping/properties/files_property.rb +16 -13
- data/lib/notion_ruby_mapping/properties/formula_property.rb +7 -7
- data/lib/notion_ruby_mapping/properties/last_edited_by_property.rb +2 -2
- data/lib/notion_ruby_mapping/properties/last_edited_time_property.rb +2 -2
- data/lib/notion_ruby_mapping/properties/multi_select_property.rb +15 -15
- data/lib/notion_ruby_mapping/properties/number_property.rb +9 -9
- data/lib/notion_ruby_mapping/properties/people_property.rb +6 -6
- data/lib/notion_ruby_mapping/properties/phone_number_property.rb +4 -4
- data/lib/notion_ruby_mapping/properties/property.rb +78 -74
- data/lib/notion_ruby_mapping/properties/relation_property.rb +18 -17
- data/lib/notion_ruby_mapping/properties/rich_text_property.rb +5 -5
- data/lib/notion_ruby_mapping/properties/rollup_property.rb +15 -15
- data/lib/notion_ruby_mapping/properties/select_property.rb +14 -14
- data/lib/notion_ruby_mapping/properties/status_property.rb +5 -5
- data/lib/notion_ruby_mapping/properties/text_property.rb +1 -1
- data/lib/notion_ruby_mapping/properties/title_property.rb +6 -6
- data/lib/notion_ruby_mapping/properties/unique_id_property.rb +3 -3
- data/lib/notion_ruby_mapping/properties/url_property.rb +3 -3
- data/lib/notion_ruby_mapping/properties/verification_property.rb +41 -0
- data/lib/notion_ruby_mapping/version.rb +1 -1
- data/lib/notion_ruby_mapping.rb +1 -1
- data/notion_ruby_mapping.gemspec +1 -2
- metadata +5 -22
- data/sig/notion_ruby_mapping.rbs +0 -4
@@ -5,16 +5,16 @@ module NotionRubyMapping
|
|
5
5
|
class MentionObject < RichTextObject
|
6
6
|
# @return [MentionObject]
|
7
7
|
def initialize(options = {})
|
8
|
-
super
|
9
|
-
return unless (url = options[
|
8
|
+
super :mention, options
|
9
|
+
return unless (url = options[:link_preview])
|
10
10
|
|
11
|
-
@options[
|
12
|
-
@options[
|
11
|
+
@options[:href] = url
|
12
|
+
@options[:plain_text] = url
|
13
13
|
end
|
14
14
|
|
15
15
|
# @return [String, NilClass]
|
16
16
|
def page_id
|
17
|
-
@options[
|
17
|
+
@options[:page_id]
|
18
18
|
end
|
19
19
|
|
20
20
|
# @return [String (frozen)]
|
@@ -23,69 +23,69 @@ module NotionRubyMapping
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def partial_property_values_json
|
26
|
-
if @options.key?
|
26
|
+
if @options.key? :user_id
|
27
27
|
{
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
type: "user",
|
29
|
+
user: {
|
30
|
+
object: "user",
|
31
|
+
id: @options[:user_id],
|
32
32
|
},
|
33
33
|
}
|
34
|
-
elsif @options.key?
|
34
|
+
elsif @options.key? :page_id
|
35
35
|
{
|
36
|
-
|
37
|
-
|
38
|
-
|
36
|
+
type: "page",
|
37
|
+
page: {
|
38
|
+
id: @options[:page_id],
|
39
39
|
},
|
40
40
|
}
|
41
|
-
elsif @options.key?
|
41
|
+
elsif @options.key? :database_id
|
42
42
|
{
|
43
|
-
|
44
|
-
|
45
|
-
|
43
|
+
type: "database",
|
44
|
+
database: {
|
45
|
+
id: @options[:database_id],
|
46
46
|
},
|
47
47
|
}
|
48
|
-
elsif @options.key?
|
48
|
+
elsif @options.key? :start
|
49
49
|
{
|
50
|
-
|
51
|
-
|
50
|
+
type: "date",
|
51
|
+
date: @options.slice(:start, :end, :time_zone),
|
52
52
|
}
|
53
|
-
elsif @options.key?
|
54
|
-
sub = case @options[
|
55
|
-
when
|
56
|
-
@options[
|
53
|
+
elsif @options.key? :template_mention
|
54
|
+
sub = case @options[:template_mention]&.to_sym
|
55
|
+
when :today
|
56
|
+
@options[:plain_text] = "@Today"
|
57
57
|
{
|
58
|
-
|
59
|
-
|
58
|
+
type: :template_mention_date,
|
59
|
+
template_mention_date: "today",
|
60
60
|
}
|
61
|
-
when
|
62
|
-
@options[
|
61
|
+
when :now
|
62
|
+
@options[:plain_text] = "@Now"
|
63
63
|
{
|
64
|
-
|
65
|
-
|
64
|
+
type: :template_mention_date,
|
65
|
+
template_mention_date: "now",
|
66
66
|
}
|
67
67
|
else
|
68
|
-
@options[
|
68
|
+
@options[:plain_text] = "@Me"
|
69
69
|
{
|
70
|
-
|
71
|
-
|
70
|
+
type: :template_mention_user,
|
71
|
+
template_mention_user: "me",
|
72
72
|
}
|
73
73
|
end
|
74
74
|
{
|
75
|
-
|
76
|
-
|
75
|
+
type: :template_mention,
|
76
|
+
template_mention: sub,
|
77
77
|
}
|
78
|
-
elsif @options.key?
|
78
|
+
elsif @options.key? :link_preview
|
79
79
|
{
|
80
|
-
|
81
|
-
|
82
|
-
|
80
|
+
type: :link_preview,
|
81
|
+
link_preview: {
|
82
|
+
url: @options[:link_preview],
|
83
83
|
},
|
84
84
|
}
|
85
|
-
elsif @options.key?
|
85
|
+
elsif @options.key? :href
|
86
86
|
{
|
87
|
-
|
88
|
-
|
87
|
+
type: :link_mention,
|
88
|
+
link_mention: @options.slice(:href, :icon_url, :link_provider, :thumbnail_url, :title),
|
89
89
|
}
|
90
90
|
else
|
91
91
|
raise StandardError, "Irregular mention type: #{@options.keys}"
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module NotionRubyMapping
|
4
4
|
# RichTextObject
|
5
5
|
class RichTextObject
|
6
|
-
# @param [
|
6
|
+
# @param [Symbol] type
|
7
7
|
# @return [TextObject]
|
8
8
|
def initialize(type, options = {})
|
9
9
|
if instance_of?(RichTextObject)
|
@@ -11,45 +11,45 @@ module NotionRubyMapping
|
|
11
11
|
"RichTextObject is abstract class. Please use TextObject."
|
12
12
|
end
|
13
13
|
|
14
|
-
@type = type
|
14
|
+
@type = type.to_sym
|
15
15
|
@options = options
|
16
16
|
end
|
17
17
|
attr_reader :will_update, :options
|
18
18
|
|
19
19
|
def self.create_from_json(json)
|
20
|
-
type = json[
|
21
|
-
options = (json[
|
20
|
+
type = json[:type]&.to_sym
|
21
|
+
options = (json[:annotations] || {}).merge(json.slice(:plain_text, :href))
|
22
22
|
case type
|
23
|
-
when
|
24
|
-
TextObject.new json[
|
25
|
-
when
|
26
|
-
EquationObject.new json[
|
27
|
-
when
|
28
|
-
mention = json[
|
29
|
-
case mention[
|
30
|
-
when
|
31
|
-
MentionObject.new options.merge({
|
32
|
-
when
|
33
|
-
MentionObject.new options.merge({
|
34
|
-
when
|
35
|
-
MentionObject.new options.merge({
|
36
|
-
when
|
37
|
-
MentionObject.new options.merge(mention[
|
38
|
-
when
|
39
|
-
template_mention = mention[
|
40
|
-
case template_mention[
|
41
|
-
when
|
42
|
-
MentionObject.new options.merge({
|
23
|
+
when :text
|
24
|
+
TextObject.new json[:plain_text], options
|
25
|
+
when :equation
|
26
|
+
EquationObject.new json[:equation][:expression], options
|
27
|
+
when :mention
|
28
|
+
mention = json[:mention]
|
29
|
+
case mention[:type]&.to_sym
|
30
|
+
when :user
|
31
|
+
MentionObject.new options.merge({user_id: mention[:user][:id]})
|
32
|
+
when :page
|
33
|
+
MentionObject.new options.merge({page_id: mention[:page][:id]})
|
34
|
+
when :database
|
35
|
+
MentionObject.new options.merge({database_id: mention[:database][:id]})
|
36
|
+
when :date
|
37
|
+
MentionObject.new options.merge(mention[:date].slice(:start, :end, :time_zone))
|
38
|
+
when :template_mention
|
39
|
+
template_mention = mention[:template_mention]
|
40
|
+
case template_mention[:type].to_sym
|
41
|
+
when :template_mention_date
|
42
|
+
MentionObject.new options.merge({template_mention: template_mention[:template_mention_date]})
|
43
43
|
else
|
44
|
-
MentionObject.new options.merge({
|
44
|
+
MentionObject.new options.merge({template_mention: template_mention[:template_mention_user]})
|
45
45
|
end
|
46
|
-
when
|
47
|
-
MentionObject.new options.merge({
|
48
|
-
when
|
49
|
-
lm_keys = %
|
50
|
-
MentionObject.new options.merge(mention[
|
46
|
+
when :link_preview
|
47
|
+
MentionObject.new options.merge({link_preview: mention[:link_preview][:url]})
|
48
|
+
when :link_mention
|
49
|
+
lm_keys = %i[href icon_url link_provider thumbnail_url title]
|
50
|
+
MentionObject.new options.merge(mention[:link_mention].slice(*lm_keys))
|
51
51
|
else
|
52
|
-
raise StandardError, "Unknown mention type: #{mention[
|
52
|
+
raise StandardError, "Unknown mention type: #{mention[:type]}"
|
53
53
|
end
|
54
54
|
else
|
55
55
|
raise StandardError, json
|
@@ -69,10 +69,10 @@ module NotionRubyMapping
|
|
69
69
|
# @return [Hash{String (frozen)->Object}]
|
70
70
|
def property_values_json
|
71
71
|
{
|
72
|
-
|
72
|
+
type: @type.to_s,
|
73
73
|
@type => partial_property_values_json,
|
74
|
-
|
75
|
-
|
74
|
+
plain_text: @options[:plain_text],
|
75
|
+
href: @options[:href],
|
76
76
|
}.merge annotations_json
|
77
77
|
end
|
78
78
|
|
@@ -85,7 +85,7 @@ module NotionRubyMapping
|
|
85
85
|
# @return [String] input text
|
86
86
|
def href=(url)
|
87
87
|
@will_update = true
|
88
|
-
@options[
|
88
|
+
@options[:href] = url
|
89
89
|
end
|
90
90
|
|
91
91
|
# @param [String, RichTextObject] value
|
@@ -98,50 +98,50 @@ module NotionRubyMapping
|
|
98
98
|
# @return [Boolean] input flag
|
99
99
|
def bold=(flag)
|
100
100
|
@will_update = true
|
101
|
-
@options[
|
101
|
+
@options[:bold] = flag
|
102
102
|
end
|
103
103
|
|
104
104
|
# @param [Boolean] flag
|
105
105
|
# @return [Boolean] input flag
|
106
106
|
def italic=(flag)
|
107
107
|
@will_update = true
|
108
|
-
@options[
|
108
|
+
@options[:italic] = flag
|
109
109
|
end
|
110
110
|
|
111
111
|
# @param [Boolean] flag
|
112
112
|
# @return [Boolean] input flag
|
113
113
|
def strikethrough=(flag)
|
114
114
|
@will_update = true
|
115
|
-
@options[
|
115
|
+
@options[:strikethrough] = flag
|
116
116
|
end
|
117
117
|
|
118
118
|
# @param [Boolean] flag
|
119
119
|
# @return [Boolean] input flag
|
120
120
|
def underline=(flag)
|
121
121
|
@will_update = true
|
122
|
-
@options[
|
122
|
+
@options[:underline] = flag
|
123
123
|
end
|
124
124
|
|
125
125
|
# @param [Boolean] flag
|
126
126
|
# @return [Boolean] input flag
|
127
127
|
def code=(flag)
|
128
128
|
@will_update = true
|
129
|
-
@options[
|
129
|
+
@options[:code] = flag
|
130
130
|
end
|
131
131
|
|
132
132
|
# @param [String] color
|
133
133
|
# @return [String] input color
|
134
134
|
def color=(color)
|
135
135
|
@will_update = true
|
136
|
-
@options[
|
136
|
+
@options[:color] = color
|
137
137
|
end
|
138
138
|
|
139
139
|
protected
|
140
140
|
|
141
141
|
# @return [Hash, Hash{String (frozen)->Hash}]
|
142
142
|
def annotations_json
|
143
|
-
annotations = @options.slice(*%
|
144
|
-
annotations.empty? ? {} : {
|
143
|
+
annotations = @options.slice(*%i[bold italic strikethrough underline code color])
|
144
|
+
annotations.empty? ? {} : {annotations: annotations}
|
145
145
|
end
|
146
146
|
end
|
147
147
|
end
|
@@ -6,7 +6,7 @@ module NotionRubyMapping
|
|
6
6
|
# @param [String] text
|
7
7
|
# @return [TextObject]
|
8
8
|
def initialize(text, options = {})
|
9
|
-
super
|
9
|
+
super :text, {plain_text: text}.merge(options)
|
10
10
|
@text = text
|
11
11
|
@will_update = false
|
12
12
|
end
|
@@ -20,17 +20,17 @@ module NotionRubyMapping
|
|
20
20
|
@text = value.text
|
21
21
|
else
|
22
22
|
@text = value
|
23
|
-
@options[
|
23
|
+
@options[:plain_text] = value
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
27
|
protected
|
28
28
|
|
29
29
|
def partial_property_values_json
|
30
|
-
url = @options[
|
30
|
+
url = @options[:href]
|
31
31
|
{
|
32
|
-
|
33
|
-
|
32
|
+
content: @text,
|
33
|
+
link: url ? {url: url} : nil,
|
34
34
|
}
|
35
35
|
end
|
36
36
|
end
|
@@ -6,7 +6,7 @@ module NotionRubyMapping
|
|
6
6
|
# @param [String] user_id
|
7
7
|
# @return [TextObject]
|
8
8
|
def initialize(user_id: nil, json: {})
|
9
|
-
@user_id = NotionCache.instance.hex_id(user_id || json && json[
|
9
|
+
@user_id = NotionCache.instance.hex_id(user_id || json && json[:id])
|
10
10
|
@json = json
|
11
11
|
@will_update = false
|
12
12
|
end
|
@@ -56,14 +56,14 @@ module NotionRubyMapping
|
|
56
56
|
|
57
57
|
# @return [String]
|
58
58
|
def name
|
59
|
-
@json[
|
59
|
+
@json[:name]
|
60
60
|
end
|
61
61
|
|
62
62
|
# @return [Hash]
|
63
63
|
def property_values_json
|
64
64
|
{
|
65
|
-
|
66
|
-
|
65
|
+
object: "user",
|
66
|
+
id: @user_id,
|
67
67
|
}
|
68
68
|
end
|
69
69
|
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module NotionRubyMapping
|
4
4
|
# Button property
|
5
5
|
class ButtonProperty < Property
|
6
|
-
TYPE =
|
6
|
+
TYPE = :button
|
7
7
|
|
8
8
|
### Public announced methods
|
9
9
|
|
@@ -14,11 +14,11 @@ module NotionRubyMapping
|
|
14
14
|
@json
|
15
15
|
end
|
16
16
|
|
17
|
-
# @param [String] name Property name
|
17
|
+
# @param [String, Symbol] name Property name
|
18
18
|
# @param [Boolean, Hash] json
|
19
19
|
def initialize(name, will_update: false, base_type: :page, property_id: nil, property_cache: nil, json: nil)
|
20
20
|
super name, will_update: will_update, base_type: base_type, property_id: property_id,
|
21
|
-
|
21
|
+
property_cache: property_cache
|
22
22
|
@json = json
|
23
23
|
end
|
24
24
|
|
@@ -27,7 +27,7 @@ module NotionRubyMapping
|
|
27
27
|
# @return [Hash]
|
28
28
|
def property_values_json
|
29
29
|
assert_page_property __method__
|
30
|
-
{@name => {
|
30
|
+
{@name => {button: @json, type: "button"}}
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
@@ -4,7 +4,7 @@ module NotionRubyMapping
|
|
4
4
|
# Checkbox property
|
5
5
|
class CheckboxProperty < Property
|
6
6
|
include EqualsDoesNotEqual
|
7
|
-
TYPE =
|
7
|
+
TYPE = :checkbox
|
8
8
|
|
9
9
|
### Public announced methods
|
10
10
|
|
@@ -31,7 +31,7 @@ module NotionRubyMapping
|
|
31
31
|
|
32
32
|
## Common methods
|
33
33
|
|
34
|
-
# @param [String] name Property name
|
34
|
+
# @param [String, Symbol] name Property name
|
35
35
|
# @param [Boolean, Hash] json
|
36
36
|
def initialize(name, will_update: false, base_type: :page, property_id: nil, property_cache: nil, json: nil)
|
37
37
|
super name, will_update: will_update, base_type: base_type, property_id: property_id,
|
@@ -48,7 +48,7 @@ module NotionRubyMapping
|
|
48
48
|
# @return [Hash]
|
49
49
|
def property_values_json
|
50
50
|
assert_page_property __method__
|
51
|
-
{@name => {
|
51
|
+
{@name => {checkbox: @json, type: "checkbox"}}
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module NotionRubyMapping
|
4
4
|
# CreatedByProperty
|
5
5
|
class CreatedByProperty < MultiProperty
|
6
|
-
TYPE =
|
6
|
+
TYPE = :created_by
|
7
7
|
|
8
8
|
### Public announced methods
|
9
9
|
|
@@ -19,7 +19,7 @@ module NotionRubyMapping
|
|
19
19
|
|
20
20
|
## Common methods
|
21
21
|
|
22
|
-
# @param [String] name Property name
|
22
|
+
# @param [String, Symbol] name Property name
|
23
23
|
# @param [String] user_id user_id (optional)
|
24
24
|
# @param [Hash] json json (optional)
|
25
25
|
def initialize(name, will_update: false, base_type: :page, json: nil, user_id: nil, property_id: nil,
|
@@ -36,7 +36,7 @@ module NotionRubyMapping
|
|
36
36
|
# @param [Hash] json
|
37
37
|
def update_from_json(json)
|
38
38
|
@will_update = false
|
39
|
-
cb = json[
|
39
|
+
cb = json[:created_by]
|
40
40
|
@json = database? ? cb : UserObject.new(json: cb)
|
41
41
|
end
|
42
42
|
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module NotionRubyMapping
|
4
4
|
# CreatedTimeProperty
|
5
5
|
class CreatedTimeProperty < DateBaseProperty
|
6
|
-
TYPE =
|
6
|
+
TYPE = :created_time
|
7
7
|
|
8
8
|
### Public announced methods
|
9
9
|
|
@@ -19,7 +19,7 @@ module NotionRubyMapping
|
|
19
19
|
|
20
20
|
## Common methods
|
21
21
|
|
22
|
-
# @param [String] name Property name
|
22
|
+
# @param [String, Symbol] name Property name
|
23
23
|
# @param [String] json created_time value (optional)
|
24
24
|
def initialize(name, will_update: false, base_type: :page, json: nil, property_id: nil, property_cache: nil)
|
25
25
|
super name, will_update: will_update, base_type: base_type, property_id: property_id,
|
@@ -59,7 +59,7 @@ module NotionRubyMapping
|
|
59
59
|
.and(filter_before(end_date, another_type: another_type))
|
60
60
|
end
|
61
61
|
else
|
62
|
-
make_filter_query
|
62
|
+
make_filter_query :equals, value_str(date), condition: condition, another_type: another_type
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
@@ -77,7 +77,7 @@ module NotionRubyMapping
|
|
77
77
|
.or(filter_after(end_date, another_type: another_type))
|
78
78
|
end
|
79
79
|
else
|
80
|
-
make_filter_query
|
80
|
+
make_filter_query :does_not_equal, value_str(date), condition: condition, another_type: another_type
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
@@ -86,7 +86,7 @@ module NotionRubyMapping
|
|
86
86
|
# @return [NotionRubyMapping::Query] generated Query object
|
87
87
|
# @see https://www.notion.so/hkob/CreatedTimeProperty-bb979ff02dc04efa9733da1003efa871#841815bfaf684964bebf3fa6712ae26c
|
88
88
|
def filter_before(date, condition: nil, another_type: nil)
|
89
|
-
make_filter_query
|
89
|
+
make_filter_query :before, value_str(date, start_time: true), condition: condition, another_type: another_type
|
90
90
|
end
|
91
91
|
|
92
92
|
# @param [String] condition Rollup name
|
@@ -94,7 +94,7 @@ module NotionRubyMapping
|
|
94
94
|
# @return [NotionRubyMapping::Query] generated Query object
|
95
95
|
# @see https://www.notion.so/hkob/CreatedTimeProperty-bb979ff02dc04efa9733da1003efa871#c0ea140866ea46f9a746b24773dc821c
|
96
96
|
def filter_after(date, condition: nil, another_type: nil)
|
97
|
-
make_filter_query
|
97
|
+
make_filter_query :after, value_str(date, end_time: true), condition: condition, another_type: another_type
|
98
98
|
end
|
99
99
|
|
100
100
|
# @param [String] condition Rollup name
|
@@ -102,7 +102,7 @@ module NotionRubyMapping
|
|
102
102
|
# @return [NotionRubyMapping::Query] generated Query object
|
103
103
|
# @see https://www.notion.so/hkob/CreatedTimeProperty-bb979ff02dc04efa9733da1003efa871#6a20ade0ee964aad81aae4c08ea29d6b
|
104
104
|
def filter_on_or_before(date, condition: nil, another_type: nil)
|
105
|
-
make_filter_query
|
105
|
+
make_filter_query :on_or_before, value_str(date, end_time: true), condition: condition, another_type: another_type
|
106
106
|
end
|
107
107
|
|
108
108
|
# @param [String] condition Rollup name
|
@@ -110,7 +110,8 @@ module NotionRubyMapping
|
|
110
110
|
# @return [NotionRubyMapping::Query] generated Query object
|
111
111
|
# @see https://www.notion.so/hkob/CreatedTimeProperty-bb979ff02dc04efa9733da1003efa871#1469e3fb3068426a8ea8492d191d1563
|
112
112
|
def filter_on_or_after(date, condition: nil, another_type: nil)
|
113
|
-
make_filter_query
|
113
|
+
make_filter_query :on_or_after, value_str(date, start_time: true), condition: condition,
|
114
|
+
another_type: another_type
|
114
115
|
end
|
115
116
|
|
116
117
|
# @param [String] condition Rollup name
|
@@ -118,7 +119,7 @@ module NotionRubyMapping
|
|
118
119
|
# @return [NotionRubyMapping::Query] generated Query object
|
119
120
|
# @see https://www.notion.so/hkob/CreatedTimeProperty-bb979ff02dc04efa9733da1003efa871#707e7e848dc9417998420b65024542db
|
120
121
|
def filter_past_week(condition: nil, another_type: nil)
|
121
|
-
make_filter_query
|
122
|
+
make_filter_query :past_week, {}, condition: condition, another_type: another_type
|
122
123
|
end
|
123
124
|
|
124
125
|
# @param [String] condition Rollup name
|
@@ -126,7 +127,7 @@ module NotionRubyMapping
|
|
126
127
|
# @return [NotionRubyMapping::Query] generated Query object
|
127
128
|
# @see https://www.notion.so/hkob/CreatedTimeProperty-bb979ff02dc04efa9733da1003efa871#7b2d05c549204c2eb68d95020d7b97c5
|
128
129
|
def filter_past_month(condition: nil, another_type: nil)
|
129
|
-
make_filter_query
|
130
|
+
make_filter_query :past_month, {}, condition: condition, another_type: another_type
|
130
131
|
end
|
131
132
|
|
132
133
|
# @param [String] condition Rollup name
|
@@ -134,7 +135,7 @@ module NotionRubyMapping
|
|
134
135
|
# @return [NotionRubyMapping::Query] generated Query object
|
135
136
|
# @see https://www.notion.so/hkob/CreatedTimeProperty-bb979ff02dc04efa9733da1003efa871#9c8bf0a2398a41c8a0714a62afca3aa8
|
136
137
|
def filter_past_year(condition: nil, another_type: nil)
|
137
|
-
make_filter_query
|
138
|
+
make_filter_query :past_year, {}, condition: condition, another_type: another_type
|
138
139
|
end
|
139
140
|
|
140
141
|
# @param [String] condition Rollup name
|
@@ -142,7 +143,7 @@ module NotionRubyMapping
|
|
142
143
|
# @return [NotionRubyMapping::Query] generated Query object
|
143
144
|
# @see
|
144
145
|
def filter_this_week(condition: nil, another_type: nil)
|
145
|
-
make_filter_query
|
146
|
+
make_filter_query :this_week, {}, condition: condition, another_type: another_type
|
146
147
|
end
|
147
148
|
|
148
149
|
# @param [String] condition Rollup name
|
@@ -150,7 +151,7 @@ module NotionRubyMapping
|
|
150
151
|
# @return [NotionRubyMapping::Query] generated Query object
|
151
152
|
# @see https://www.notion.so/hkob/CreatedTimeProperty-bb979ff02dc04efa9733da1003efa871#d9dc189ee8244ba8a6c863259eaa9984
|
152
153
|
def filter_next_week(condition: nil, another_type: nil)
|
153
|
-
make_filter_query
|
154
|
+
make_filter_query :next_week, {}, condition: condition, another_type: another_type
|
154
155
|
end
|
155
156
|
|
156
157
|
# @param [String] condition Rollup name
|
@@ -158,7 +159,7 @@ module NotionRubyMapping
|
|
158
159
|
# @return [NotionRubyMapping::Query] generated Query object
|
159
160
|
# @see https://www.notion.so/hkob/CreatedTimeProperty-bb979ff02dc04efa9733da1003efa871#0edb4dffbe6b403882255e870cc71066
|
160
161
|
def filter_next_month(condition: nil, another_type: nil)
|
161
|
-
make_filter_query
|
162
|
+
make_filter_query :next_month, {}, condition: condition, another_type: another_type
|
162
163
|
end
|
163
164
|
|
164
165
|
# @param [String] condition Rollup name
|
@@ -166,7 +167,7 @@ module NotionRubyMapping
|
|
166
167
|
# @return [NotionRubyMapping::Query] generated Query object
|
167
168
|
# @see https://www.notion.so/hkob/CreatedTimeProperty-bb979ff02dc04efa9733da1003efa871#b59c73dd4b1a488f95d3e8cd19853709
|
168
169
|
def filter_next_year(condition: nil, another_type: nil)
|
169
|
-
make_filter_query
|
170
|
+
make_filter_query :next_year, {}, condition: condition, another_type: another_type
|
170
171
|
end
|
171
172
|
|
172
173
|
# @param [Date, Time, DateTime, String, nil] obj
|