notion_ruby_mapping 0.3.3 → 0.4.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 +33 -1228
- data/env.yml.sample +0 -13
- data/lib/notion_ruby_mapping/{base.rb → blocks/base.rb} +155 -88
- data/lib/notion_ruby_mapping/blocks/block.rb +547 -0
- data/lib/notion_ruby_mapping/{database.rb → blocks/database.rb} +34 -7
- data/lib/notion_ruby_mapping/{list.rb → blocks/list.rb} +35 -3
- data/lib/notion_ruby_mapping/blocks/page.rb +71 -0
- data/lib/notion_ruby_mapping/{notion_cache.rb → controllers/notion_cache.rb} +128 -102
- data/lib/notion_ruby_mapping/{payload.rb → controllers/payload.rb} +0 -0
- data/lib/notion_ruby_mapping/{property_cache.rb → controllers/property_cache.rb} +21 -20
- data/lib/notion_ruby_mapping/{query.rb → controllers/query.rb} +26 -18
- data/lib/notion_ruby_mapping/{rich_text_array.rb → controllers/rich_text_array.rb} +26 -15
- data/lib/notion_ruby_mapping/objects/emoji_object.rb +40 -0
- data/lib/notion_ruby_mapping/objects/equation_object.rb +43 -0
- data/lib/notion_ruby_mapping/objects/file_object.rb +60 -0
- data/lib/notion_ruby_mapping/{mention_object.rb → objects/mention_object.rb} +11 -0
- data/lib/notion_ruby_mapping/{rich_text_object.rb → objects/rich_text_object.rb} +11 -0
- data/lib/notion_ruby_mapping/{text_object.rb → objects/text_object.rb} +0 -1
- data/lib/notion_ruby_mapping/{user_object.rb → objects/user_object.rb} +9 -4
- data/lib/notion_ruby_mapping/{checkbox_property.rb → properties/checkbox_property.rb} +3 -0
- data/lib/notion_ruby_mapping/{created_by_property.rb → properties/created_by_property.rb} +0 -0
- data/lib/notion_ruby_mapping/{created_time_property.rb → properties/created_time_property.rb} +1 -0
- data/lib/notion_ruby_mapping/properties/date_base_property.rb +122 -0
- data/lib/notion_ruby_mapping/{date_property.rb → properties/date_property.rb} +13 -0
- data/lib/notion_ruby_mapping/{email_property.rb → properties/email_property.rb} +1 -0
- data/lib/notion_ruby_mapping/{files_property.rb → properties/files_property.rb} +26 -13
- data/lib/notion_ruby_mapping/{formula_property.rb → properties/formula_property.rb} +4 -0
- data/lib/notion_ruby_mapping/{last_edited_by_property.rb → properties/last_edited_by_property.rb} +1 -0
- data/lib/notion_ruby_mapping/{last_edited_time_property.rb → properties/last_edited_time_property.rb} +1 -0
- data/lib/notion_ruby_mapping/{multi_property.rb → properties/multi_property.rb} +0 -0
- data/lib/notion_ruby_mapping/{multi_select_property.rb → properties/multi_select_property.rb} +2 -3
- data/lib/notion_ruby_mapping/{number_property.rb → properties/number_property.rb} +4 -0
- data/lib/notion_ruby_mapping/{people_property.rb → properties/people_property.rb} +8 -3
- data/lib/notion_ruby_mapping/{phone_number_property.rb → properties/phone_number_property.rb} +4 -0
- data/lib/notion_ruby_mapping/{property.rb → properties/property.rb} +33 -0
- data/lib/notion_ruby_mapping/{relation_property.rb → properties/relation_property.rb} +30 -10
- data/lib/notion_ruby_mapping/{rich_text_property.rb → properties/rich_text_property.rb} +0 -0
- data/lib/notion_ruby_mapping/{rollup_property.rb → properties/rollup_property.rb} +7 -0
- data/lib/notion_ruby_mapping/{select_property.rb → properties/select_property.rb} +6 -1
- data/lib/notion_ruby_mapping/{text_property.rb → properties/text_property.rb} +0 -0
- data/lib/notion_ruby_mapping/{title_property.rb → properties/title_property.rb} +0 -0
- data/lib/notion_ruby_mapping/{url_property.rb → properties/url_property.rb} +5 -0
- data/lib/notion_ruby_mapping/version.rb +1 -1
- data/lib/notion_ruby_mapping.rb +14 -7
- metadata +43 -40
- data/lib/notion_ruby_mapping/block.rb +0 -10
- data/lib/notion_ruby_mapping/date_base_property.rb +0 -75
- data/lib/notion_ruby_mapping/page.rb +0 -50
@@ -91,6 +91,8 @@ module NotionRubyMapping
|
|
91
91
|
def make_filter_query(key, value, rollup = nil, rollup_type = nil)
|
92
92
|
if rollup
|
93
93
|
Query.new filter: {"property" => @name, rollup => {rollup_type => {key => value}}}
|
94
|
+
elsif rollup_type
|
95
|
+
Query.new filter: {"property" => @name, rollup_type => {key => value}}
|
94
96
|
elsif @name == "__timestamp__"
|
95
97
|
Query.new filter: {"timestamp" => type, type => {key => value}}
|
96
98
|
else
|
@@ -169,13 +171,19 @@ module NotionRubyMapping
|
|
169
171
|
### Public announced methods
|
170
172
|
|
171
173
|
# @param [String, Number] value Query value
|
174
|
+
# @param [String] rollup Rollup name
|
175
|
+
# @param [String] rollup_type Rollup type
|
172
176
|
# @return [NotionRubyMapping::Query] generated Query object
|
177
|
+
# @see https://www.notion.so/hkob/CheckboxProperty-ac1edbdb8e264af5ad1432b522b429fd#5f07c4ebc4744986bfc99a43827349fc
|
173
178
|
def filter_equals(value, rollup = nil, rollup_type = nil)
|
174
179
|
make_filter_query "equals", value, rollup, rollup_type
|
175
180
|
end
|
176
181
|
|
177
182
|
# @param [String, Number] value Query value
|
183
|
+
# @param [String] rollup Rollup name
|
184
|
+
# @param [String] rollup_type Rollup type
|
178
185
|
# @return [NotionRubyMapping::Query] generated Query object
|
186
|
+
# @see https://www.notion.so/hkob/CheckboxProperty-ac1edbdb8e264af5ad1432b522b429fd#a44a1875c3ef49f2b4f817291953a1d4
|
179
187
|
def filter_does_not_equal(value, rollup = nil, rollup_type = nil)
|
180
188
|
make_filter_query "does_not_equal", value, rollup, rollup_type
|
181
189
|
end
|
@@ -186,13 +194,19 @@ module NotionRubyMapping
|
|
186
194
|
### Public announced methods
|
187
195
|
|
188
196
|
# @param [String] value Query value
|
197
|
+
# @param [String] rollup Rollup name
|
198
|
+
# @param [String] rollup_type Rollup type
|
189
199
|
# @return [NotionRubyMapping::Query] generated Query object
|
200
|
+
# @see https://www.notion.so/hkob/CreatedByProperty-945fa6be1c014da2b7e55a2b76e37b57#271a2ebaa1ec48acae732ca98920feab
|
190
201
|
def filter_contains(value, rollup = nil, rollup_type = nil)
|
191
202
|
make_filter_query "contains", value, rollup, rollup_type
|
192
203
|
end
|
193
204
|
|
194
205
|
# @param [String] value Query value
|
206
|
+
# @param [String] rollup Rollup name
|
207
|
+
# @param [String] rollup_type Rollup type
|
195
208
|
# @return [NotionRubyMapping::Query] generated Query object
|
209
|
+
# @see https://www.notion.so/hkob/CreatedByProperty-945fa6be1c014da2b7e55a2b76e37b57#b0328e3b146f48a4ad4c9c2ee5363486
|
196
210
|
def filter_does_not_contain(value, rollup = nil, rollup_type = nil)
|
197
211
|
make_filter_query "does_not_contain", value, rollup, rollup_type
|
198
212
|
end
|
@@ -203,12 +217,17 @@ module NotionRubyMapping
|
|
203
217
|
### Public announced methods
|
204
218
|
|
205
219
|
# @param [String] value Query value
|
220
|
+
# @param [String] rollup Rollup name
|
221
|
+
# @param [String] rollup_type Rollup type
|
206
222
|
# @return [NotionRubyMapping::Query] generated Query object
|
223
|
+
# @see https://www.notion.so/hkob/EmailProperty-39aeb5df56ea4cc1b9380574e4fdeec0#d3e098b2f38c4c8c9d3e815516cfd953
|
207
224
|
def filter_starts_with(value, rollup = nil, rollup_type = nil)
|
208
225
|
make_filter_query "starts_with", value, rollup, rollup_type
|
209
226
|
end
|
210
227
|
|
211
228
|
# @param [String] value Query value
|
229
|
+
# @param [String] rollup Rollup name
|
230
|
+
# @param [String] rollup_type Rollup type
|
212
231
|
# @return [NotionRubyMapping::Query] generated Query object
|
213
232
|
def filter_ends_with(value, rollup = nil, rollup_type = nil)
|
214
233
|
make_filter_query "ends_with", value, rollup, rollup_type
|
@@ -219,12 +238,18 @@ module NotionRubyMapping
|
|
219
238
|
module IsEmptyIsNotEmpty
|
220
239
|
### Public announced methods
|
221
240
|
|
241
|
+
# @param [String] rollup Rollup name
|
242
|
+
# @param [String] rollup_type Rollup type
|
222
243
|
# @return [NotionRubyMapping::Query] generated Query object
|
244
|
+
# @see https://www.notion.so/hkob/CreatedByProperty-945fa6be1c014da2b7e55a2b76e37b57#38749dfae0854c68b4c55095d3efbff1
|
223
245
|
def filter_is_empty(rollup = nil, rollup_type = nil)
|
224
246
|
make_filter_query "is_empty", true, rollup, rollup_type
|
225
247
|
end
|
226
248
|
|
249
|
+
# @param [String] rollup Rollup name
|
250
|
+
# @param [String] rollup_type Rollup type
|
227
251
|
# @return [NotionRubyMapping::Query] generated Query object
|
252
|
+
# @see https://www.notion.so/hkob/CreatedByProperty-945fa6be1c014da2b7e55a2b76e37b57#515659ea52b54fb48c81b813f3b705f6
|
228
253
|
def filter_is_not_empty(rollup = nil, rollup_type = nil)
|
229
254
|
make_filter_query "is_not_empty", true, rollup, rollup_type
|
230
255
|
end
|
@@ -235,24 +260,32 @@ module NotionRubyMapping
|
|
235
260
|
### Public announced methods
|
236
261
|
|
237
262
|
# @param [Number] value Query value
|
263
|
+
# @param [String] rollup Rollup name
|
264
|
+
# @param [String] rollup_type Rollup type
|
238
265
|
# @return [NotionRubyMapping::Query] generated Query object
|
239
266
|
def filter_greater_than(value, rollup = nil, rollup_type = nil)
|
240
267
|
make_filter_query "greater_than", value, rollup, rollup_type
|
241
268
|
end
|
242
269
|
|
243
270
|
# @param [Number] value Query value
|
271
|
+
# @param [String] rollup Rollup name
|
272
|
+
# @param [String] rollup_type Rollup type
|
244
273
|
# @return [NotionRubyMapping::Query] generated Query object
|
245
274
|
def filter_less_than(value, rollup = nil, rollup_type = nil)
|
246
275
|
make_filter_query "less_than", value, rollup, rollup_type
|
247
276
|
end
|
248
277
|
|
249
278
|
# @param [Number] value Query value
|
279
|
+
# @param [String] rollup Rollup name
|
280
|
+
# @param [String] rollup_type Rollup type
|
250
281
|
# @return [NotionRubyMapping::Query] generated Query object
|
251
282
|
def filter_greater_than_or_equal_to(value, rollup = nil, rollup_type = nil)
|
252
283
|
make_filter_query "greater_than_or_equal_to", value, rollup, rollup_type
|
253
284
|
end
|
254
285
|
|
255
286
|
# @param [Number] value Query value
|
287
|
+
# @param [String] rollup Rollup name
|
288
|
+
# @param [String] rollup_type Rollup type
|
256
289
|
# @return [NotionRubyMapping::Query] generated Query object
|
257
290
|
def filter_less_than_or_equal_to(value, rollup = nil, rollup_type = nil)
|
258
291
|
make_filter_query "less_than_or_equal_to", value, rollup, rollup_type
|
@@ -10,13 +10,42 @@ module NotionRubyMapping
|
|
10
10
|
## Common methods
|
11
11
|
|
12
12
|
# @return [Hash, Array]
|
13
|
+
# @see https://www.notion.so/hkob/RelationProperty-f608ab41a1f0476b98456620346fba03#6c14207b2d1340d2bbc08d17eee2cb22
|
13
14
|
def relation
|
14
15
|
@json
|
15
16
|
end
|
16
17
|
|
18
|
+
## Page property only methods
|
19
|
+
|
20
|
+
# @param [String, Hash] page_id_or_json
|
21
|
+
# @see https://www.notion.so/hkob/RelationProperty-f608ab41a1f0476b98456620346fba03#52572d8745ef4b66bc34ba202c84b87c
|
22
|
+
def add_relation(page_id_or_json)
|
23
|
+
assert_page_property __method__
|
24
|
+
@will_update = true
|
25
|
+
@json << if page_id_or_json.is_a? String
|
26
|
+
{"id" => page_id_or_json}
|
27
|
+
else
|
28
|
+
page_id_or_json
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# @param [String, Array<String>, Hash, Array<Hash>] page_ids_or_jsons
|
33
|
+
# @return [Array] settled relation Array
|
34
|
+
# @see https://www.notion.so/hkob/RelationProperty-f608ab41a1f0476b98456620346fba03#1025f772ecd64e678912a5036a95eda6
|
35
|
+
def relation=(page_ids_or_jsons)
|
36
|
+
assert_page_property __method__
|
37
|
+
@will_update = true
|
38
|
+
page_ids_or_jsons = [page_ids_or_jsons] unless page_ids_or_jsons.is_a? Array
|
39
|
+
|
40
|
+
@json = page_ids_or_jsons.map do |page_id_or_json|
|
41
|
+
page_id_or_json.is_a?(String) ? {"id" => page_id_or_json} : page_id_or_json
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
17
45
|
## Database property only methods
|
18
46
|
|
19
47
|
# @return [String] relation database_id
|
48
|
+
# @see https://www.notion.so/hkob/RelationProperty-f608ab41a1f0476b98456620346fba03#eb40f1a2ad5c4e368d343870a7e529f9
|
20
49
|
def relation_database_id
|
21
50
|
assert_database_property __method__
|
22
51
|
@json["database_id"]
|
@@ -24,6 +53,7 @@ module NotionRubyMapping
|
|
24
53
|
|
25
54
|
# @param [String] database_id
|
26
55
|
# @param [String] synced_property_name
|
56
|
+
# @see https://www.notion.so/hkob/RelationProperty-f608ab41a1f0476b98456620346fba03#7f5029fb7f6e4c009f22888b233e6f64
|
27
57
|
def replace_relation_database(database_id: nil, synced_property_name: nil)
|
28
58
|
assert_database_property __method__
|
29
59
|
@will_update = true
|
@@ -65,16 +95,6 @@ module NotionRubyMapping
|
|
65
95
|
ans
|
66
96
|
end
|
67
97
|
|
68
|
-
## Page property only methods
|
69
|
-
|
70
|
-
# @param [String, Array<String>] relation a id or Array of id
|
71
|
-
# @return [Array] settled relation Array
|
72
|
-
def relation=(page_ids)
|
73
|
-
assert_page_property __method__
|
74
|
-
@will_update = true
|
75
|
-
@json = Array(page_ids).map { |r| {"id" => r} }
|
76
|
-
end
|
77
|
-
|
78
98
|
# @return [Hash] created json
|
79
99
|
def property_values_json
|
80
100
|
assert_page_property __method__
|
File without changes
|
@@ -13,6 +13,7 @@ module NotionRubyMapping
|
|
13
13
|
## Common methods
|
14
14
|
|
15
15
|
# @return [Hash]
|
16
|
+
# @see https://www.notion.so/hkob/RollupProperty-eb10fbac3a93436289e74e5c651e9134#4b5749f350e542e5a018030bde411fb9
|
16
17
|
def rollup
|
17
18
|
@json
|
18
19
|
end
|
@@ -20,12 +21,14 @@ module NotionRubyMapping
|
|
20
21
|
## Database property only methods
|
21
22
|
|
22
23
|
# @return [String] new or settled function
|
24
|
+
# @see https://www.notion.so/hkob/RollupProperty-eb10fbac3a93436289e74e5c651e9134#94021d4e6c0b44519443c1e1cc6b3aba
|
23
25
|
def function
|
24
26
|
assert_database_property __method__
|
25
27
|
@json["function"]
|
26
28
|
end
|
27
29
|
|
28
30
|
# @param [String] func
|
31
|
+
# @see https://www.notion.so/hkob/RollupProperty-eb10fbac3a93436289e74e5c651e9134#647c74803cac49a9b79199828157e17a
|
29
32
|
def function=(func)
|
30
33
|
assert_database_property __method__
|
31
34
|
@will_update = true
|
@@ -33,12 +36,14 @@ module NotionRubyMapping
|
|
33
36
|
end
|
34
37
|
|
35
38
|
# @return [String] new or settled relation_property_name
|
39
|
+
# @see https://www.notion.so/hkob/RollupProperty-eb10fbac3a93436289e74e5c651e9134#684fc4739c4f4d6a9b93687f72cd8dad
|
36
40
|
def relation_property_name
|
37
41
|
assert_database_property __method__
|
38
42
|
@json["relation_property_name"]
|
39
43
|
end
|
40
44
|
|
41
45
|
# @param [String] rpn
|
46
|
+
# @see https://www.notion.so/hkob/RollupProperty-eb10fbac3a93436289e74e5c651e9134#a61c2100758841c381edd820aa88ac65
|
42
47
|
def relation_property_name=(rpn)
|
43
48
|
assert_database_property __method__
|
44
49
|
@will_update = true
|
@@ -46,12 +51,14 @@ module NotionRubyMapping
|
|
46
51
|
end
|
47
52
|
|
48
53
|
# @return [String] new or settled rollup_property_name
|
54
|
+
# @see https://www.notion.so/hkob/RollupProperty-eb10fbac3a93436289e74e5c651e9134#8ce9ee31a2e2473ab7ba21781e4b440d
|
49
55
|
def rollup_property_name
|
50
56
|
assert_database_property __method__
|
51
57
|
@json["rollup_property_name"]
|
52
58
|
end
|
53
59
|
|
54
60
|
# @param [String] rpn
|
61
|
+
# @see https://www.notion.so/hkob/RollupProperty-eb10fbac3a93436289e74e5c651e9134#66503f4472f2456aa9b383f03b1fe0a6
|
55
62
|
def rollup_property_name=(rpn)
|
56
63
|
assert_database_property __method__
|
57
64
|
@will_update = true
|
@@ -12,6 +12,7 @@ module NotionRubyMapping
|
|
12
12
|
## Common methods
|
13
13
|
|
14
14
|
# @return [Hash]
|
15
|
+
# @see https://www.notion.so/hkob/SelectProperty-6d6a0defa70d4b26af0fdbdcfbf99f28#7ad3734ac42c43068f1e04633bab400b
|
15
16
|
def select
|
16
17
|
@json
|
17
18
|
end
|
@@ -19,6 +20,7 @@ module NotionRubyMapping
|
|
19
20
|
## Page property only methods
|
20
21
|
|
21
22
|
# @return [String]
|
23
|
+
# @see https://www.notion.so/hkob/SelectProperty-6d6a0defa70d4b26af0fdbdcfbf99f28#27a05e52715a4acd9156b5f146653e51
|
22
24
|
def select_name
|
23
25
|
assert_page_property __method__
|
24
26
|
@json["name"]
|
@@ -29,7 +31,8 @@ module NotionRubyMapping
|
|
29
31
|
# @param [String] name
|
30
32
|
# @param [String] color
|
31
33
|
# @return [Array] added array
|
32
|
-
|
34
|
+
# @see https://www.notion.so/hkob/SelectProperty-6d6a0defa70d4b26af0fdbdcfbf99f28#3e1c7dbda7fb455f94ee93d9653b7880
|
35
|
+
def add_select_option(name:, color:)
|
33
36
|
edit_select_options << {"name" => name, "color" => color}
|
34
37
|
end
|
35
38
|
|
@@ -41,12 +44,14 @@ module NotionRubyMapping
|
|
41
44
|
end
|
42
45
|
|
43
46
|
# @return [Array]
|
47
|
+
# @see https://www.notion.so/hkob/SelectProperty-6d6a0defa70d4b26af0fdbdcfbf99f28#790a297f2c1b4ba5a4d86074d4c70a89
|
44
48
|
def select_options
|
45
49
|
assert_database_property __method__
|
46
50
|
@json["options"] || []
|
47
51
|
end
|
48
52
|
|
49
53
|
# @return [String]
|
54
|
+
# @see https://www.notion.so/hkob/SelectProperty-6d6a0defa70d4b26af0fdbdcfbf99f28#72da1632793c4a5296f3bc89de2df413
|
50
55
|
def select_names
|
51
56
|
assert_database_property __method__
|
52
57
|
@json["options"].map { |s| s["name"] }
|
File without changes
|
File without changes
|
@@ -14,13 +14,18 @@ module NotionRubyMapping
|
|
14
14
|
## Common methods
|
15
15
|
|
16
16
|
# @return [String, Hash, nil] url (Page), {} (Database)
|
17
|
+
# @see https://www.notion.so/hkob/UrlProperty-8a0094fdf6494151983cb4694f6626cc#8342eef7df3c43eaad10c48d4757b4ae
|
17
18
|
def url
|
18
19
|
@json
|
19
20
|
end
|
20
21
|
|
21
22
|
## Page property only methods
|
22
23
|
|
24
|
+
|
25
|
+
# @param [String] url
|
26
|
+
# @see https://www.notion.so/hkob/UrlProperty-8a0094fdf6494151983cb4694f6626cc#cfa5463a121b4002b250b38d7d0a0d34
|
23
27
|
def url=(url)
|
28
|
+
assert_page_property __method__
|
24
29
|
@will_update = true
|
25
30
|
@json = url
|
26
31
|
end
|
data/lib/notion_ruby_mapping.rb
CHANGED
@@ -2,11 +2,18 @@
|
|
2
2
|
|
3
3
|
require "yaml"
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
5
|
+
require_relative "notion_ruby_mapping/version"
|
6
|
+
{
|
7
|
+
blocks: %w[base block database list page],
|
8
|
+
controllers: %w[notion_cache payload property_cache query rich_text_array],
|
9
|
+
objects: %w[rich_text_object emoji_object equation_object file_object mention_object text_object user_object],
|
10
|
+
properties: %w[property checkbox_property multi_property created_by_property date_base_property created_time_property
|
11
|
+
date_property email_property files_property formula_property last_edited_by_property
|
12
|
+
last_edited_time_property multi_select_property number_property people_property phone_number_property
|
13
|
+
relation_property text_property rich_text_property rollup_property select_property title_property
|
14
|
+
url_property],
|
15
|
+
}.each do |key, values|
|
16
|
+
values.each do |klass|
|
17
|
+
require_relative "notion_ruby_mapping/#{key}/#{klass}"
|
18
|
+
end
|
12
19
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: notion_ruby_mapping
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hiroyuki KOBAYASHI
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-05-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -148,43 +148,46 @@ files:
|
|
148
148
|
- images/pre_set_icon.png
|
149
149
|
- images/serial_number.png
|
150
150
|
- lib/notion_ruby_mapping.rb
|
151
|
-
- lib/notion_ruby_mapping/base.rb
|
152
|
-
- lib/notion_ruby_mapping/block.rb
|
153
|
-
- lib/notion_ruby_mapping/
|
154
|
-
- lib/notion_ruby_mapping/
|
155
|
-
- lib/notion_ruby_mapping/
|
156
|
-
- lib/notion_ruby_mapping/
|
157
|
-
- lib/notion_ruby_mapping/
|
158
|
-
- lib/notion_ruby_mapping/
|
159
|
-
- lib/notion_ruby_mapping/
|
160
|
-
- lib/notion_ruby_mapping/
|
161
|
-
- lib/notion_ruby_mapping/
|
162
|
-
- lib/notion_ruby_mapping/
|
163
|
-
- lib/notion_ruby_mapping/
|
164
|
-
- lib/notion_ruby_mapping/
|
165
|
-
- lib/notion_ruby_mapping/
|
166
|
-
- lib/notion_ruby_mapping/
|
167
|
-
- lib/notion_ruby_mapping/
|
168
|
-
- lib/notion_ruby_mapping/
|
169
|
-
- lib/notion_ruby_mapping/
|
170
|
-
- lib/notion_ruby_mapping/
|
171
|
-
- lib/notion_ruby_mapping/
|
172
|
-
- lib/notion_ruby_mapping/
|
173
|
-
- lib/notion_ruby_mapping/
|
174
|
-
- lib/notion_ruby_mapping/
|
175
|
-
- lib/notion_ruby_mapping/
|
176
|
-
- lib/notion_ruby_mapping/
|
177
|
-
- lib/notion_ruby_mapping/
|
178
|
-
- lib/notion_ruby_mapping/
|
179
|
-
- lib/notion_ruby_mapping/
|
180
|
-
- lib/notion_ruby_mapping/
|
181
|
-
- lib/notion_ruby_mapping/
|
182
|
-
- lib/notion_ruby_mapping/
|
183
|
-
- lib/notion_ruby_mapping/
|
184
|
-
- lib/notion_ruby_mapping/
|
185
|
-
- lib/notion_ruby_mapping/
|
186
|
-
- lib/notion_ruby_mapping/
|
187
|
-
- lib/notion_ruby_mapping/
|
151
|
+
- lib/notion_ruby_mapping/blocks/base.rb
|
152
|
+
- lib/notion_ruby_mapping/blocks/block.rb
|
153
|
+
- lib/notion_ruby_mapping/blocks/database.rb
|
154
|
+
- lib/notion_ruby_mapping/blocks/list.rb
|
155
|
+
- lib/notion_ruby_mapping/blocks/page.rb
|
156
|
+
- lib/notion_ruby_mapping/controllers/notion_cache.rb
|
157
|
+
- lib/notion_ruby_mapping/controllers/payload.rb
|
158
|
+
- lib/notion_ruby_mapping/controllers/property_cache.rb
|
159
|
+
- lib/notion_ruby_mapping/controllers/query.rb
|
160
|
+
- lib/notion_ruby_mapping/controllers/rich_text_array.rb
|
161
|
+
- lib/notion_ruby_mapping/objects/emoji_object.rb
|
162
|
+
- lib/notion_ruby_mapping/objects/equation_object.rb
|
163
|
+
- lib/notion_ruby_mapping/objects/file_object.rb
|
164
|
+
- lib/notion_ruby_mapping/objects/mention_object.rb
|
165
|
+
- lib/notion_ruby_mapping/objects/rich_text_object.rb
|
166
|
+
- lib/notion_ruby_mapping/objects/text_object.rb
|
167
|
+
- lib/notion_ruby_mapping/objects/user_object.rb
|
168
|
+
- lib/notion_ruby_mapping/properties/checkbox_property.rb
|
169
|
+
- lib/notion_ruby_mapping/properties/created_by_property.rb
|
170
|
+
- lib/notion_ruby_mapping/properties/created_time_property.rb
|
171
|
+
- lib/notion_ruby_mapping/properties/date_base_property.rb
|
172
|
+
- lib/notion_ruby_mapping/properties/date_property.rb
|
173
|
+
- lib/notion_ruby_mapping/properties/email_property.rb
|
174
|
+
- lib/notion_ruby_mapping/properties/files_property.rb
|
175
|
+
- lib/notion_ruby_mapping/properties/formula_property.rb
|
176
|
+
- lib/notion_ruby_mapping/properties/last_edited_by_property.rb
|
177
|
+
- lib/notion_ruby_mapping/properties/last_edited_time_property.rb
|
178
|
+
- lib/notion_ruby_mapping/properties/multi_property.rb
|
179
|
+
- lib/notion_ruby_mapping/properties/multi_select_property.rb
|
180
|
+
- lib/notion_ruby_mapping/properties/number_property.rb
|
181
|
+
- lib/notion_ruby_mapping/properties/people_property.rb
|
182
|
+
- lib/notion_ruby_mapping/properties/phone_number_property.rb
|
183
|
+
- lib/notion_ruby_mapping/properties/property.rb
|
184
|
+
- lib/notion_ruby_mapping/properties/relation_property.rb
|
185
|
+
- lib/notion_ruby_mapping/properties/rich_text_property.rb
|
186
|
+
- lib/notion_ruby_mapping/properties/rollup_property.rb
|
187
|
+
- lib/notion_ruby_mapping/properties/select_property.rb
|
188
|
+
- lib/notion_ruby_mapping/properties/text_property.rb
|
189
|
+
- lib/notion_ruby_mapping/properties/title_property.rb
|
190
|
+
- lib/notion_ruby_mapping/properties/url_property.rb
|
188
191
|
- lib/notion_ruby_mapping/version.rb
|
189
192
|
- notion_ruby_mapping.gemspec
|
190
193
|
- sig/notion_ruby_mapping.rbs
|
@@ -208,7 +211,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
208
211
|
- !ruby/object:Gem::Version
|
209
212
|
version: '0'
|
210
213
|
requirements: []
|
211
|
-
rubygems_version: 3.3.
|
214
|
+
rubygems_version: 3.3.7
|
212
215
|
signing_key:
|
213
216
|
specification_version: 4
|
214
217
|
summary: Notion Ruby mapping tool
|
@@ -1,75 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "date"
|
4
|
-
|
5
|
-
module NotionRubyMapping
|
6
|
-
# Date base property (date, created_time, last_edited_time, formula)
|
7
|
-
class DateBaseProperty < Property
|
8
|
-
include IsEmptyIsNotEmpty
|
9
|
-
|
10
|
-
def filter_equals(date, rollup = nil, rollup_type = nil)
|
11
|
-
make_filter_query "equals", value_str(date), rollup, rollup_type
|
12
|
-
end
|
13
|
-
|
14
|
-
def filter_does_not_equal(date, rollup = nil, rollup_type = nil)
|
15
|
-
make_filter_query "does_not_equal", value_str(date), rollup, rollup_type
|
16
|
-
end
|
17
|
-
|
18
|
-
def filter_before(date, rollup = nil, rollup_type = nil)
|
19
|
-
make_filter_query "before", value_str(date), rollup, rollup_type
|
20
|
-
end
|
21
|
-
|
22
|
-
def filter_after(date, rollup = nil, rollup_type = nil)
|
23
|
-
make_filter_query "after", value_str(date), rollup, rollup_type
|
24
|
-
end
|
25
|
-
|
26
|
-
def filter_on_or_before(date, rollup = nil, rollup_type = nil)
|
27
|
-
make_filter_query "on_or_before", value_str(date), rollup, rollup_type
|
28
|
-
end
|
29
|
-
|
30
|
-
def filter_on_or_after(date, rollup = nil, rollup_type = nil)
|
31
|
-
make_filter_query "on_or_after", value_str(date), rollup, rollup_type
|
32
|
-
end
|
33
|
-
|
34
|
-
def filter_past_week(rollup = nil, rollup_type = nil)
|
35
|
-
make_filter_query "past_week", {}, rollup, rollup_type
|
36
|
-
end
|
37
|
-
|
38
|
-
def filter_past_month(rollup = nil, rollup_type = nil)
|
39
|
-
make_filter_query "past_month", {}, rollup, rollup_type
|
40
|
-
end
|
41
|
-
|
42
|
-
def filter_past_year(rollup = nil, rollup_type = nil)
|
43
|
-
make_filter_query "past_year", {}, rollup, rollup_type
|
44
|
-
end
|
45
|
-
|
46
|
-
def filter_next_week(rollup = nil, rollup_type = nil)
|
47
|
-
make_filter_query "next_week", {}, rollup, rollup_type
|
48
|
-
end
|
49
|
-
|
50
|
-
def filter_next_month(rollup = nil, rollup_type = nil)
|
51
|
-
make_filter_query "next_month", {}, rollup, rollup_type
|
52
|
-
end
|
53
|
-
|
54
|
-
def filter_next_year(rollup = nil, rollup_type = nil)
|
55
|
-
make_filter_query "next_year", {}, rollup, rollup_type
|
56
|
-
end
|
57
|
-
|
58
|
-
protected
|
59
|
-
|
60
|
-
# @param [Date, Time, DateTime, String, nil] obj
|
61
|
-
# @return [String] iso8601 format string
|
62
|
-
def value_str(obj)
|
63
|
-
case obj
|
64
|
-
when Date
|
65
|
-
obj.iso8601
|
66
|
-
when Time
|
67
|
-
obj.strftime("%Y-%m-%dT%H:%M:%S%:z")
|
68
|
-
when DateTime
|
69
|
-
obj.iso8601
|
70
|
-
else
|
71
|
-
obj
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module NotionRubyMapping
|
4
|
-
# Notion page object
|
5
|
-
class Page < Base
|
6
|
-
### Public announced methods
|
7
|
-
|
8
|
-
# @param [String] id
|
9
|
-
# @return [NotionRubyMapping::Page, String]
|
10
|
-
def self.find(id, dry_run: false)
|
11
|
-
nc = NotionCache.instance
|
12
|
-
if dry_run
|
13
|
-
Base.dry_run_script :get, nc.page_path(id)
|
14
|
-
else
|
15
|
-
nc.page id
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def create_child_database(title, *assign)
|
20
|
-
Database.new json: {"title" => [TextObject.new(title).property_values_json]},
|
21
|
-
assign: assign, parent: {"type" => "page_id", "page_id" => @id}
|
22
|
-
end
|
23
|
-
|
24
|
-
protected
|
25
|
-
|
26
|
-
# @return [NotionRubyMapping::Base, String]
|
27
|
-
def create(dry_run: false)
|
28
|
-
if dry_run
|
29
|
-
dry_run_script :post, @nc.pages_path, :property_values_json
|
30
|
-
else
|
31
|
-
@new_record = false
|
32
|
-
update_json @nc.create_page_request(property_values_json)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
# @return [Hash]
|
37
|
-
def reload_json
|
38
|
-
@nc.page_request @id
|
39
|
-
end
|
40
|
-
|
41
|
-
# @return [NotionRubyMapping::Base, String]
|
42
|
-
def update(dry_run: false)
|
43
|
-
if dry_run
|
44
|
-
dry_run_script :patch, @nc.page_path(@id), :property_values_json
|
45
|
-
else
|
46
|
-
update_json @nc.update_page_request(@id, property_values_json)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|