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
@@ -34,7 +34,7 @@ module NotionRubyMapping
|
|
34
34
|
def self.start_end_time(date)
|
35
35
|
ds = date.iso8601
|
36
36
|
tz = Time.now.strftime "%:z"
|
37
|
-
%w[00:00:00 23:59:59].map {|t| [ds, "T", t, tz].join("") }
|
37
|
+
%w[00:00:00 23:59:59].map { |t| [ds, "T", t, tz].join("") }
|
38
38
|
end
|
39
39
|
|
40
40
|
# @param [Date, Time, DateTime, String, nil] obj
|
@@ -44,119 +44,121 @@ module NotionRubyMapping
|
|
44
44
|
Date.parse str if str
|
45
45
|
end
|
46
46
|
|
47
|
-
# @param [String]
|
48
|
-
# @param [String]
|
47
|
+
# @param [String] condition Rollup name
|
48
|
+
# @param [String] another_type Rollup type
|
49
49
|
# @return [NotionRubyMapping::Query] generated Query object
|
50
50
|
# @see https://www.notion.so/hkob/CheckboxProperty-ac1edbdb8e264af5ad1432b522b429fd#5f07c4ebc4744986bfc99a43827349fc
|
51
|
-
def filter_equals(date,
|
51
|
+
def filter_equals(date, condition: nil, another_type: nil)
|
52
52
|
if date.is_a? Date
|
53
53
|
start_date, end_date = self.class.start_end_time date
|
54
|
-
if
|
55
|
-
filter_after(start_date,
|
56
|
-
.and(filter_before(end_date,
|
54
|
+
if condition
|
55
|
+
filter_after(start_date, condition: condition, another_type: another_type)
|
56
|
+
.and(filter_before(end_date, condition: condition, another_type: another_type))
|
57
57
|
else
|
58
|
-
filter_after(start_date
|
58
|
+
filter_after(start_date, another_type: another_type)
|
59
|
+
.and(filter_before(end_date, another_type: another_type))
|
59
60
|
end
|
60
61
|
else
|
61
|
-
make_filter_query "equals", value_str(date),
|
62
|
+
make_filter_query "equals", value_str(date), condition: condition, another_type: another_type
|
62
63
|
end
|
63
64
|
end
|
64
65
|
|
65
|
-
# @param [String]
|
66
|
-
# @param [String]
|
66
|
+
# @param [String] condition Rollup name
|
67
|
+
# @param [String] another_type Rollup type
|
67
68
|
# @return [NotionRubyMapping::Query] generated Query object
|
68
|
-
def filter_does_not_equal(date,
|
69
|
+
def filter_does_not_equal(date, condition: nil, another_type: nil)
|
69
70
|
if date.is_a? Date
|
70
71
|
start_date, end_date = self.class.start_end_time date
|
71
|
-
if
|
72
|
-
filter_before(start_date,
|
73
|
-
.or(filter_after(end_date,
|
72
|
+
if condition
|
73
|
+
filter_before(start_date, condition: condition, another_type: another_type)
|
74
|
+
.or(filter_after(end_date, condition: condition, another_type: another_type))
|
74
75
|
else
|
75
|
-
filter_before(start_date)
|
76
|
+
filter_before(start_date, another_type: another_type)
|
77
|
+
.or(filter_after(end_date, another_type: another_type))
|
76
78
|
end
|
77
79
|
else
|
78
|
-
make_filter_query "does_not_equal", value_str(date),
|
80
|
+
make_filter_query "does_not_equal", value_str(date), condition: condition, another_type: another_type
|
79
81
|
end
|
80
82
|
end
|
81
83
|
|
82
|
-
# @param [String]
|
83
|
-
# @param [String]
|
84
|
+
# @param [String] condition Rollup name
|
85
|
+
# @param [String] another_type Rollup type
|
84
86
|
# @return [NotionRubyMapping::Query] generated Query object
|
85
87
|
# @see https://www.notion.so/hkob/CreatedTimeProperty-bb979ff02dc04efa9733da1003efa871#841815bfaf684964bebf3fa6712ae26c
|
86
|
-
def filter_before(date,
|
87
|
-
make_filter_query "before", value_str(date, start_time: true),
|
88
|
+
def filter_before(date, condition: nil, another_type: nil)
|
89
|
+
make_filter_query "before", value_str(date, start_time: true), condition: condition, another_type: another_type
|
88
90
|
end
|
89
91
|
|
90
|
-
# @param [String]
|
91
|
-
# @param [String]
|
92
|
+
# @param [String] condition Rollup name
|
93
|
+
# @param [String] another_type Rollup type
|
92
94
|
# @return [NotionRubyMapping::Query] generated Query object
|
93
95
|
# @see https://www.notion.so/hkob/CreatedTimeProperty-bb979ff02dc04efa9733da1003efa871#c0ea140866ea46f9a746b24773dc821c
|
94
|
-
def filter_after(date,
|
95
|
-
make_filter_query "after", value_str(date, end_time: true),
|
96
|
+
def filter_after(date, condition: nil, another_type: nil)
|
97
|
+
make_filter_query "after", value_str(date, end_time: true), condition: condition, another_type: another_type
|
96
98
|
end
|
97
99
|
|
98
|
-
# @param [String]
|
99
|
-
# @param [String]
|
100
|
+
# @param [String] condition Rollup name
|
101
|
+
# @param [String] another_type Rollup type
|
100
102
|
# @return [NotionRubyMapping::Query] generated Query object
|
101
103
|
# @see https://www.notion.so/hkob/CreatedTimeProperty-bb979ff02dc04efa9733da1003efa871#6a20ade0ee964aad81aae4c08ea29d6b
|
102
|
-
def filter_on_or_before(date,
|
103
|
-
make_filter_query "on_or_before", value_str(date, end_time: true),
|
104
|
+
def filter_on_or_before(date, condition: nil, another_type: nil)
|
105
|
+
make_filter_query "on_or_before", value_str(date, end_time: true), condition: condition, another_type: another_type
|
104
106
|
end
|
105
107
|
|
106
|
-
# @param [String]
|
107
|
-
# @param [String]
|
108
|
+
# @param [String] condition Rollup name
|
109
|
+
# @param [String] another_type Rollup type
|
108
110
|
# @return [NotionRubyMapping::Query] generated Query object
|
109
111
|
# @see https://www.notion.so/hkob/CreatedTimeProperty-bb979ff02dc04efa9733da1003efa871#1469e3fb3068426a8ea8492d191d1563
|
110
|
-
def filter_on_or_after(date,
|
111
|
-
make_filter_query "on_or_after", value_str(date, start_time: true),
|
112
|
+
def filter_on_or_after(date, condition: nil, another_type: nil)
|
113
|
+
make_filter_query "on_or_after", value_str(date, start_time: true), condition: condition, another_type: another_type
|
112
114
|
end
|
113
115
|
|
114
|
-
# @param [String]
|
115
|
-
# @param [String]
|
116
|
+
# @param [String] condition Rollup name
|
117
|
+
# @param [String] another_type Rollup type
|
116
118
|
# @return [NotionRubyMapping::Query] generated Query object
|
117
119
|
# @see https://www.notion.so/hkob/CreatedTimeProperty-bb979ff02dc04efa9733da1003efa871#707e7e848dc9417998420b65024542db
|
118
|
-
def filter_past_week(
|
119
|
-
make_filter_query "past_week", {},
|
120
|
+
def filter_past_week(condition: nil, another_type: nil)
|
121
|
+
make_filter_query "past_week", {}, condition: condition, another_type: another_type
|
120
122
|
end
|
121
123
|
|
122
|
-
# @param [String]
|
123
|
-
# @param [String]
|
124
|
+
# @param [String] condition Rollup name
|
125
|
+
# @param [String] another_type Rollup type
|
124
126
|
# @return [NotionRubyMapping::Query] generated Query object
|
125
127
|
# @see https://www.notion.so/hkob/CreatedTimeProperty-bb979ff02dc04efa9733da1003efa871#7b2d05c549204c2eb68d95020d7b97c5
|
126
|
-
def filter_past_month(
|
127
|
-
make_filter_query "past_month", {},
|
128
|
+
def filter_past_month(condition: nil, another_type: nil)
|
129
|
+
make_filter_query "past_month", {}, condition: condition, another_type: another_type
|
128
130
|
end
|
129
131
|
|
130
|
-
# @param [String]
|
131
|
-
# @param [String]
|
132
|
+
# @param [String] condition Rollup name
|
133
|
+
# @param [String] another_type Rollup type
|
132
134
|
# @return [NotionRubyMapping::Query] generated Query object
|
133
135
|
# @see https://www.notion.so/hkob/CreatedTimeProperty-bb979ff02dc04efa9733da1003efa871#9c8bf0a2398a41c8a0714a62afca3aa8
|
134
|
-
def filter_past_year(
|
135
|
-
make_filter_query "past_year", {},
|
136
|
+
def filter_past_year(condition: nil, another_type: nil)
|
137
|
+
make_filter_query "past_year", {}, condition: condition, another_type: another_type
|
136
138
|
end
|
137
139
|
|
138
|
-
# @param [String]
|
139
|
-
# @param [String]
|
140
|
+
# @param [String] condition Rollup name
|
141
|
+
# @param [String] another_type Rollup type
|
140
142
|
# @return [NotionRubyMapping::Query] generated Query object
|
141
143
|
# @see https://www.notion.so/hkob/CreatedTimeProperty-bb979ff02dc04efa9733da1003efa871#d9dc189ee8244ba8a6c863259eaa9984
|
142
|
-
def filter_next_week(
|
143
|
-
make_filter_query "next_week", {},
|
144
|
+
def filter_next_week(condition: nil, another_type: nil)
|
145
|
+
make_filter_query "next_week", {}, condition: condition, another_type: another_type
|
144
146
|
end
|
145
147
|
|
146
|
-
# @param [String]
|
147
|
-
# @param [String]
|
148
|
+
# @param [String] condition Rollup name
|
149
|
+
# @param [String] another_type Rollup type
|
148
150
|
# @return [NotionRubyMapping::Query] generated Query object
|
149
151
|
# @see https://www.notion.so/hkob/CreatedTimeProperty-bb979ff02dc04efa9733da1003efa871#0edb4dffbe6b403882255e870cc71066
|
150
|
-
def filter_next_month(
|
151
|
-
make_filter_query "next_month", {},
|
152
|
+
def filter_next_month(condition: nil, another_type: nil)
|
153
|
+
make_filter_query "next_month", {}, condition: condition, another_type: another_type
|
152
154
|
end
|
153
155
|
|
154
|
-
# @param [String]
|
155
|
-
# @param [String]
|
156
|
+
# @param [String] condition Rollup name
|
157
|
+
# @param [String] another_type Rollup type
|
156
158
|
# @return [NotionRubyMapping::Query] generated Query object
|
157
159
|
# @see https://www.notion.so/hkob/CreatedTimeProperty-bb979ff02dc04efa9733da1003efa871#b59c73dd4b1a488f95d3e8cd19853709
|
158
|
-
def filter_next_year(
|
159
|
-
make_filter_query "next_year", {},
|
160
|
+
def filter_next_year(condition: nil, another_type: nil)
|
161
|
+
make_filter_query "next_year", {}, condition: condition, another_type: another_type
|
160
162
|
end
|
161
163
|
|
162
164
|
# @param [Date, Time, DateTime, String, nil] obj
|
@@ -29,8 +29,8 @@ module NotionRubyMapping
|
|
29
29
|
def end_date=(edt)
|
30
30
|
assert_page_property __method__
|
31
31
|
@will_update = true
|
32
|
-
sdt = start_date
|
33
|
-
edt = nil if sdt.class != edt.class || sdt > edt
|
32
|
+
# sdt = start_date
|
33
|
+
# edt = nil if sdt.class != edt.class || sdt > edt
|
34
34
|
@json["end"] = edt
|
35
35
|
end
|
36
36
|
|
@@ -46,8 +46,8 @@ module NotionRubyMapping
|
|
46
46
|
def start_date=(sdt)
|
47
47
|
assert_page_property __method__
|
48
48
|
@will_update = true
|
49
|
-
edt = end_date
|
50
|
-
@json["end"] = nil if sdt.class != edt.class || sdt > edt
|
49
|
+
# edt = end_date
|
50
|
+
# @json["end"] = nil if sdt.class != edt.class || sdt > edt
|
51
51
|
@json["start"] = sdt
|
52
52
|
end
|
53
53
|
|
@@ -75,8 +75,10 @@ module NotionRubyMapping
|
|
75
75
|
# @param [Date, Time, DateTime, String, nil] start_date
|
76
76
|
# @param [Date, Time, DateTime, String, nil] end_date
|
77
77
|
# @param [String, nil] time_zone
|
78
|
-
def initialize(name, will_update: false, base_type: :page, json: nil, start_date: nil, end_date: nil,
|
79
|
-
|
78
|
+
def initialize(name, will_update: false, base_type: :page, json: nil, start_date: nil, end_date: nil,
|
79
|
+
time_zone: nil, property_id: nil, property_cache: nil)
|
80
|
+
super name, will_update: will_update, base_type: base_type, property_id: property_id,
|
81
|
+
property_cache: property_cache
|
80
82
|
@json = json || {}
|
81
83
|
return if database?
|
82
84
|
|
@@ -32,8 +32,9 @@ module NotionRubyMapping
|
|
32
32
|
## Common methods
|
33
33
|
|
34
34
|
# @param [String] name Property name
|
35
|
-
def initialize(name, will_update: false, base_type: :page, json: nil, property_cache: nil)
|
36
|
-
super name, will_update: will_update, base_type: base_type,
|
35
|
+
def initialize(name, will_update: false, base_type: :page, json: nil, property_id: nil, property_cache: nil)
|
36
|
+
super name, will_update: will_update, base_type: base_type, property_id: property_id,
|
37
|
+
property_cache: property_cache
|
37
38
|
@json = json || {}
|
38
39
|
end
|
39
40
|
|
@@ -33,8 +33,10 @@ module NotionRubyMapping
|
|
33
33
|
|
34
34
|
# @param [String] name Property name
|
35
35
|
# @param [String] files files value (optional)
|
36
|
-
def initialize(name, will_update: false, base_type: :page, json: nil, files: [],
|
37
|
-
|
36
|
+
def initialize(name, will_update: false, base_type: :page, json: nil, files: [], property_id: nil,
|
37
|
+
property_cache: nil)
|
38
|
+
super name, will_update: will_update, base_type: base_type, property_id: property_id,
|
39
|
+
property_cache: property_cache
|
38
40
|
if database?
|
39
41
|
@files = json || {}
|
40
42
|
elsif json
|
@@ -41,8 +41,10 @@ module NotionRubyMapping
|
|
41
41
|
|
42
42
|
# @param [String] name
|
43
43
|
# @param [Hash] json
|
44
|
-
def initialize(name, will_update: false, base_type: :page, json: nil, formula: nil,
|
45
|
-
|
44
|
+
def initialize(name, will_update: false, base_type: :page, json: nil, formula: nil, property_id: nil,
|
45
|
+
property_cache: nil)
|
46
|
+
super name, will_update: will_update, base_type: base_type, property_id: property_id,
|
47
|
+
property_cache: property_cache
|
46
48
|
@json = json || {}
|
47
49
|
return unless database?
|
48
50
|
|
@@ -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 last_edited_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
|
@@ -61,8 +61,10 @@ module NotionRubyMapping
|
|
61
61
|
# @param [String] name
|
62
62
|
# @param [Hash] json
|
63
63
|
# @param [Array<String>, String] multi_select
|
64
|
-
def initialize(name, will_update: false, base_type: :page, json: nil, multi_select: nil,
|
65
|
-
|
64
|
+
def initialize(name, will_update: false, base_type: :page, json: nil, multi_select: nil,
|
65
|
+
property_id: nil, property_cache: nil)
|
66
|
+
super name, will_update: will_update, base_type: base_type, property_id: property_id,
|
67
|
+
property_cache: property_cache
|
66
68
|
if database?
|
67
69
|
@json = json || {"options" => []}
|
68
70
|
else
|
@@ -12,7 +12,7 @@ module NotionRubyMapping
|
|
12
12
|
|
13
13
|
## Common methods
|
14
14
|
|
15
|
-
# @return [Numeric, Hash]
|
15
|
+
# @return [Numeric, Hash, nil]
|
16
16
|
# @see https://www.notion.so/hkob/NumberProperty-964ebc1948074d7ca8340187aa352d40#571b41dd33ae42039e6b982a502b7ac7
|
17
17
|
def number
|
18
18
|
@json
|
@@ -53,8 +53,10 @@ module NotionRubyMapping
|
|
53
53
|
|
54
54
|
# @param [String] name Property name
|
55
55
|
# @param [Float, Integer, Hash] json Number value or format Hash
|
56
|
-
def initialize(name, will_update: false, base_type: :page, json: nil, format: nil,
|
57
|
-
|
56
|
+
def initialize(name, will_update: false, base_type: :page, json: nil, format: nil, property_id: nil,
|
57
|
+
property_cache: nil)
|
58
|
+
super name, will_update: will_update, base_type: base_type, property_id: property_id,
|
59
|
+
property_cache: property_cache
|
58
60
|
@json = json
|
59
61
|
@json ||= {"format" => (format || "number")} if database?
|
60
62
|
end
|
@@ -40,14 +40,22 @@ module NotionRubyMapping
|
|
40
40
|
## Common methods
|
41
41
|
|
42
42
|
def self.people_from_json(json)
|
43
|
-
|
43
|
+
if json.is_a? Array
|
44
|
+
json.map { |sub_json| UserObject.new json: sub_json }
|
45
|
+
elsif json["object"] == "list"
|
46
|
+
List.new(json: json, type: :property, value: self).select { true }
|
47
|
+
else
|
48
|
+
json["people"].map { |sub_json| UserObject.new json: sub_json }
|
49
|
+
end
|
44
50
|
end
|
45
51
|
|
46
52
|
# @param [String] name
|
47
53
|
# @param [Hash] json
|
48
54
|
# @param [Array] people ids for people
|
49
|
-
def initialize(name, will_update: false, base_type: :page, json: nil, people: nil,
|
50
|
-
|
55
|
+
def initialize(name, will_update: false, base_type: :page, json: nil, people: nil, property_id: nil,
|
56
|
+
property_cache: nil, query: nil)
|
57
|
+
super name, will_update: will_update, base_type: base_type, property_id: property_id,
|
58
|
+
property_cache: property_cache, query: query
|
51
59
|
@json = if database?
|
52
60
|
{}
|
53
61
|
elsif people
|
@@ -34,8 +34,9 @@ module NotionRubyMapping
|
|
34
34
|
## Common methods
|
35
35
|
|
36
36
|
# @param [String] name Property name
|
37
|
-
def initialize(name, will_update: false, base_type: :page, json: nil, property_cache: nil)
|
38
|
-
super name, will_update: will_update, base_type: base_type,
|
37
|
+
def initialize(name, will_update: false, base_type: :page, json: nil, property_id: nil, property_cache: nil)
|
38
|
+
super name, will_update: will_update, base_type: base_type, property_id: property_id,
|
39
|
+
property_cache: property_cache
|
39
40
|
@json = database? ? {} : json
|
40
41
|
end
|
41
42
|
|
@@ -76,18 +76,23 @@ module NotionRubyMapping
|
|
76
76
|
elsif type == "property_item"
|
77
77
|
tmp = new name, property_id: input_json["property_item"]["id"], base_type: base_type,
|
78
78
|
property_cache: property_cache, query: query
|
79
|
-
objects = List.new(json: input_json, property: tmp, query: query).
|
79
|
+
objects = List.new(json: input_json, type: :property, value: tmp, query: query).to_a
|
80
80
|
case input_json["property_item"]["type"]
|
81
81
|
when "people"
|
82
|
-
PeopleProperty.new name, people: objects, base_type: base_type,
|
82
|
+
PeopleProperty.new name, people: objects, base_type: base_type,
|
83
|
+
property_cache: property_cache, query: query
|
83
84
|
when "relation"
|
84
|
-
RelationProperty.new name, relation: objects, base_type: base_type,
|
85
|
+
RelationProperty.new name, relation: objects, base_type: base_type,
|
86
|
+
property_cache: property_cache, query: query
|
85
87
|
when "rich_text"
|
86
|
-
RichTextProperty.new name, text_objects: objects, base_type: base_type,
|
88
|
+
RichTextProperty.new name, text_objects: objects, base_type: base_type,
|
89
|
+
property_cache: property_cache, query: query
|
87
90
|
when "rollup"
|
88
|
-
RollupProperty.new name, json: objects, base_type: base_type,
|
91
|
+
RollupProperty.new name, json: objects, base_type: base_type,
|
92
|
+
property_cache: property_cache, query: query
|
89
93
|
when "title"
|
90
|
-
TitleProperty.new name, text_objects: objects, base_type: base_type,
|
94
|
+
TitleProperty.new name, text_objects: objects, base_type: base_type,
|
95
|
+
property_cache: property_cache, query: query
|
91
96
|
end
|
92
97
|
else
|
93
98
|
klass = {
|
@@ -114,7 +119,8 @@ module NotionRubyMapping
|
|
114
119
|
}[type]
|
115
120
|
raise StandardError, "Irregular property type: #{type}" unless klass
|
116
121
|
|
117
|
-
klass.new name, json: input_json[type], base_type: base_type,
|
122
|
+
klass.new name, property_id: input_json["id"], json: input_json[type], base_type: base_type,
|
123
|
+
property_cache: property_cache
|
118
124
|
end
|
119
125
|
end
|
120
126
|
|
@@ -136,11 +142,13 @@ module NotionRubyMapping
|
|
136
142
|
# @param [String] key query parameter
|
137
143
|
# @param [Object] value query value
|
138
144
|
# @return [NotionRubyMapping::Query] generated Query object
|
139
|
-
def make_filter_query(key, value,
|
140
|
-
if
|
141
|
-
Query.new filter: {"property" => @name,
|
142
|
-
elsif
|
143
|
-
Query.new filter: {"property" => @name,
|
145
|
+
def make_filter_query(key, value, condition: nil, another_type: nil)
|
146
|
+
if is_a? FormulaProperty
|
147
|
+
Query.new filter: {"property" => @name, "formula" => {another_type => {key => value}}}
|
148
|
+
elsif condition
|
149
|
+
Query.new filter: {"property" => @name, condition => {another_type => {key => value}}}
|
150
|
+
elsif another_type
|
151
|
+
Query.new filter: {"property" => @name, another_type => {key => value}}
|
144
152
|
elsif @name == "__timestamp__"
|
145
153
|
Query.new filter: {"timestamp" => type, type => {key => value}}
|
146
154
|
else
|
@@ -229,8 +237,8 @@ module NotionRubyMapping
|
|
229
237
|
# @param [String] rollup_type Rollup type
|
230
238
|
# @return [NotionRubyMapping::Query] generated Query object
|
231
239
|
# @see https://www.notion.so/hkob/CheckboxProperty-ac1edbdb8e264af5ad1432b522b429fd#5f07c4ebc4744986bfc99a43827349fc
|
232
|
-
def filter_equals(value,
|
233
|
-
make_filter_query "equals", value,
|
240
|
+
def filter_equals(value, condition: nil, another_type: nil)
|
241
|
+
make_filter_query "equals", value, condition: condition, another_type: another_type
|
234
242
|
end
|
235
243
|
|
236
244
|
# @param [String, Number] value Query value
|
@@ -238,8 +246,8 @@ module NotionRubyMapping
|
|
238
246
|
# @param [String] rollup_type Rollup type
|
239
247
|
# @return [NotionRubyMapping::Query] generated Query object
|
240
248
|
# @see https://www.notion.so/hkob/CheckboxProperty-ac1edbdb8e264af5ad1432b522b429fd#a44a1875c3ef49f2b4f817291953a1d4
|
241
|
-
def filter_does_not_equal(value,
|
242
|
-
make_filter_query "does_not_equal", value,
|
249
|
+
def filter_does_not_equal(value, condition: nil, another_type: nil)
|
250
|
+
make_filter_query "does_not_equal", value, condition: condition, another_type: another_type
|
243
251
|
end
|
244
252
|
end
|
245
253
|
|
@@ -252,8 +260,8 @@ module NotionRubyMapping
|
|
252
260
|
# @param [String] rollup_type Rollup type
|
253
261
|
# @return [NotionRubyMapping::Query] generated Query object
|
254
262
|
# @see https://www.notion.so/hkob/CreatedByProperty-945fa6be1c014da2b7e55a2b76e37b57#271a2ebaa1ec48acae732ca98920feab
|
255
|
-
def filter_contains(value,
|
256
|
-
make_filter_query "contains", value,
|
263
|
+
def filter_contains(value, condition: nil, another_type: nil)
|
264
|
+
make_filter_query "contains", value, condition: condition, another_type: another_type
|
257
265
|
end
|
258
266
|
|
259
267
|
# @param [String] value Query value
|
@@ -261,8 +269,8 @@ module NotionRubyMapping
|
|
261
269
|
# @param [String] rollup_type Rollup type
|
262
270
|
# @return [NotionRubyMapping::Query] generated Query object
|
263
271
|
# @see https://www.notion.so/hkob/CreatedByProperty-945fa6be1c014da2b7e55a2b76e37b57#b0328e3b146f48a4ad4c9c2ee5363486
|
264
|
-
def filter_does_not_contain(value,
|
265
|
-
make_filter_query "does_not_contain", value,
|
272
|
+
def filter_does_not_contain(value, condition: nil, another_type: nil)
|
273
|
+
make_filter_query "does_not_contain", value, condition: condition, another_type: another_type
|
266
274
|
end
|
267
275
|
end
|
268
276
|
|
@@ -275,16 +283,16 @@ module NotionRubyMapping
|
|
275
283
|
# @param [String] rollup_type Rollup type
|
276
284
|
# @return [NotionRubyMapping::Query] generated Query object
|
277
285
|
# @see https://www.notion.so/hkob/EmailProperty-39aeb5df56ea4cc1b9380574e4fdeec0#d3e098b2f38c4c8c9d3e815516cfd953
|
278
|
-
def filter_starts_with(value,
|
279
|
-
make_filter_query "starts_with", value,
|
286
|
+
def filter_starts_with(value, condition: nil, another_type: nil)
|
287
|
+
make_filter_query "starts_with", value, condition: condition, another_type: another_type
|
280
288
|
end
|
281
289
|
|
282
290
|
# @param [String] value Query value
|
283
291
|
# @param [String] rollup Rollup name
|
284
292
|
# @param [String] rollup_type Rollup type
|
285
293
|
# @return [NotionRubyMapping::Query] generated Query object
|
286
|
-
def filter_ends_with(value,
|
287
|
-
make_filter_query "ends_with", value,
|
294
|
+
def filter_ends_with(value, condition: nil, another_type: nil)
|
295
|
+
make_filter_query "ends_with", value, condition: condition, another_type: another_type
|
288
296
|
end
|
289
297
|
end
|
290
298
|
|
@@ -296,16 +304,16 @@ module NotionRubyMapping
|
|
296
304
|
# @param [String] rollup_type Rollup type
|
297
305
|
# @return [NotionRubyMapping::Query] generated Query object
|
298
306
|
# @see https://www.notion.so/hkob/CreatedByProperty-945fa6be1c014da2b7e55a2b76e37b57#38749dfae0854c68b4c55095d3efbff1
|
299
|
-
def filter_is_empty(
|
300
|
-
make_filter_query "is_empty", true,
|
307
|
+
def filter_is_empty(condition: nil, another_type: nil)
|
308
|
+
make_filter_query "is_empty", true, condition: condition, another_type: another_type
|
301
309
|
end
|
302
310
|
|
303
311
|
# @param [String] rollup Rollup name
|
304
312
|
# @param [String] rollup_type Rollup type
|
305
313
|
# @return [NotionRubyMapping::Query] generated Query object
|
306
314
|
# @see https://www.notion.so/hkob/CreatedByProperty-945fa6be1c014da2b7e55a2b76e37b57#515659ea52b54fb48c81b813f3b705f6
|
307
|
-
def filter_is_not_empty(
|
308
|
-
make_filter_query "is_not_empty", true,
|
315
|
+
def filter_is_not_empty(condition: nil, another_type: nil)
|
316
|
+
make_filter_query "is_not_empty", true, condition: condition, another_type: another_type
|
309
317
|
end
|
310
318
|
end
|
311
319
|
|
@@ -317,32 +325,32 @@ module NotionRubyMapping
|
|
317
325
|
# @param [String] rollup Rollup name
|
318
326
|
# @param [String] rollup_type Rollup type
|
319
327
|
# @return [NotionRubyMapping::Query] generated Query object
|
320
|
-
def filter_greater_than(value,
|
321
|
-
make_filter_query "greater_than", value,
|
328
|
+
def filter_greater_than(value, condition: nil, another_type: nil)
|
329
|
+
make_filter_query "greater_than", value, condition: condition, another_type: another_type
|
322
330
|
end
|
323
331
|
|
324
332
|
# @param [Number] value Query value
|
325
333
|
# @param [String] rollup Rollup name
|
326
334
|
# @param [String] rollup_type Rollup type
|
327
335
|
# @return [NotionRubyMapping::Query] generated Query object
|
328
|
-
def filter_less_than(value,
|
329
|
-
make_filter_query "less_than", value,
|
336
|
+
def filter_less_than(value, condition: nil, another_type: nil)
|
337
|
+
make_filter_query "less_than", value, condition: condition, another_type: another_type
|
330
338
|
end
|
331
339
|
|
332
340
|
# @param [Number] value Query value
|
333
341
|
# @param [String] rollup Rollup name
|
334
342
|
# @param [String] rollup_type Rollup type
|
335
343
|
# @return [NotionRubyMapping::Query] generated Query object
|
336
|
-
def filter_greater_than_or_equal_to(value,
|
337
|
-
make_filter_query "greater_than_or_equal_to", value,
|
344
|
+
def filter_greater_than_or_equal_to(value, condition: nil, another_type: nil)
|
345
|
+
make_filter_query "greater_than_or_equal_to", value, condition: condition, another_type: another_type
|
338
346
|
end
|
339
347
|
|
340
348
|
# @param [Number] value Query value
|
341
349
|
# @param [String] rollup Rollup name
|
342
350
|
# @param [String] rollup_type Rollup type
|
343
351
|
# @return [NotionRubyMapping::Query] generated Query object
|
344
|
-
def filter_less_than_or_equal_to(value,
|
345
|
-
make_filter_query "less_than_or_equal_to", value,
|
352
|
+
def filter_less_than_or_equal_to(value, condition: nil, another_type: nil)
|
353
|
+
make_filter_query "less_than_or_equal_to", value, condition: condition, another_type: another_type
|
346
354
|
end
|
347
355
|
end
|
348
356
|
end
|
@@ -9,7 +9,7 @@ module NotionRubyMapping
|
|
9
9
|
|
10
10
|
## Common methods
|
11
11
|
|
12
|
-
# @return [Hash, Array]
|
12
|
+
# @return [Hash, Array, nil]
|
13
13
|
# @see https://www.notion.so/hkob/RelationProperty-f608ab41a1f0476b98456620346fba03#6c14207b2d1340d2bbc08d17eee2cb22
|
14
14
|
def relation
|
15
15
|
@json
|
@@ -70,16 +70,16 @@ module NotionRubyMapping
|
|
70
70
|
# @param [String] name
|
71
71
|
# @param [Hash, Array] json
|
72
72
|
# @param [String, Array] relation
|
73
|
-
def initialize(name, will_update: false, json: nil, relation: nil, base_type: :page,
|
74
|
-
|
73
|
+
def initialize(name, will_update: false, json: nil, relation: nil, base_type: :page, property_id: nil,
|
74
|
+
property_cache: nil, query: nil)
|
75
|
+
super name, will_update: will_update, base_type: base_type, property_id: property_id,
|
76
|
+
property_cache: property_cache, query: query
|
75
77
|
@json = if database?
|
76
78
|
json || {}
|
77
79
|
elsif relation
|
78
80
|
Array(relation).map { |r| {"id" => r} }
|
79
|
-
elsif json
|
80
|
-
json
|
81
81
|
else
|
82
|
-
[]
|
82
|
+
json || []
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
@@ -71,8 +71,10 @@ module NotionRubyMapping
|
|
71
71
|
|
72
72
|
# @param [String] name
|
73
73
|
# @param [Hash] json
|
74
|
-
def initialize(name, will_update: false, json: nil, base_type: :page,
|
75
|
-
|
74
|
+
def initialize(name, will_update: false, json: nil, base_type: :page, property_id: nil,
|
75
|
+
property_cache: nil, query: nil)
|
76
|
+
super name, will_update: will_update, base_type: base_type, property_id: property_id,
|
77
|
+
property_cache: property_cache, query: query
|
76
78
|
@json = json || {}
|
77
79
|
end
|
78
80
|
|
@@ -74,8 +74,10 @@ module NotionRubyMapping
|
|
74
74
|
# @param [String] name Property name
|
75
75
|
# @param [Hash] json
|
76
76
|
# @param [String] select String value (optional)
|
77
|
-
def initialize(name, will_update: false, base_type: :page, json: nil, select: nil,
|
78
|
-
|
77
|
+
def initialize(name, will_update: false, base_type: :page, json: nil, select: nil, property_id: nil,
|
78
|
+
property_cache: nil)
|
79
|
+
super name, will_update: will_update, base_type: base_type, property_id: property_id,
|
80
|
+
property_cache: property_cache
|
79
81
|
@json = if database?
|
80
82
|
json || {"options" => []}
|
81
83
|
else
|