notion_ruby_mapping 0.6.6 → 0.6.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/lib/notion_ruby_mapping/blocks/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/page.rb +2 -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/property_cache.rb +4 -0
- data/lib/notion_ruby_mapping/properties/checkbox_property.rb +3 -2
- 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_property.rb +4 -2
- 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 +4 -2
- 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 +12 -6
- data/lib/notion_ruby_mapping/properties/relation_property.rb +4 -2
- 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: b9297c2ca59117bacfab46da55e60bda063c3a08a1bfc0acdd5b8e9b7b029c52
|
|
4
|
+
data.tar.gz: fdcfc87ab82132cebedf50f99c174793c74e952cc35608b60935e2bd158a2df6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0f01ba2a798cd79e608b244a6c9c0157f92b1f7e2f9bd4fd4772b38e60f708d1da5a70ffda0816b8aa136282da49d118ff04ede19a363674c3277b3095a34e91
|
|
7
|
+
data.tar.gz: 6135423f52bdc33585247ef2c144a49492b54a28d18ae7429d8f4df9791f4d4189d570c2b381b89f939d0b2e2e1914276172b603f612038dbfc7c495ea250c01
|
data/README.md
CHANGED
|
@@ -92,6 +92,7 @@ NotionCache.instance.create_client ENV["NOTION_API_TOKEN"] # from environment
|
|
|
92
92
|
|
|
93
93
|
## 3. ChangeLog
|
|
94
94
|
|
|
95
|
+
- 2022/9/2 [v0.6.7] add support for Status property, is_toggleable for headings block, and page property values
|
|
95
96
|
- 2022/8/10 [v0.6.6] Bug fix(notionSitemap.rb): Skip if child page is empty.
|
|
96
97
|
- 2022/8/10 [v0.6.5] add notionSitemap.rb, rename createErDiagram to notionErDiagram, and move them to exe directory
|
|
97
98
|
- 2022/8/9 [v0.6.4] url can be entered instead of page_id, block_id and database_id
|
|
@@ -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
|
|
@@ -47,7 +47,7 @@ module NotionRubyMapping
|
|
|
47
47
|
|
|
48
48
|
# @param [String] title
|
|
49
49
|
# @param [Array<String, Property>] assigns
|
|
50
|
-
# @return [NotionRubyMapping::Database]
|
|
50
|
+
# @return [NotionRubyMapping::Database, String]
|
|
51
51
|
# @see https://www.notion.so/hkob/Page-d359650e3ca94424af8359a24147b9a0#e3f1d21e0f724f589e48431468772eed
|
|
52
52
|
def create_child_database(title, *assigns, dry_run: false)
|
|
53
53
|
build_child_database(title, *assigns).save dry_run: dry_run
|
|
@@ -56,7 +56,7 @@ module NotionRubyMapping
|
|
|
56
56
|
# @return [String] title
|
|
57
57
|
# @see https://www.notion.so/hkob/Page-d359650e3ca94424af8359a24147b9a0#2ff7209055f346fbbda454cdbb40b1c8
|
|
58
58
|
def title
|
|
59
|
-
tp = properties.select { |p|
|
|
59
|
+
tp = properties.select { |p| p.is_a?(TitleProperty) || (p.is_a?(Property) && p.property_id == "title") }
|
|
60
60
|
tp.map(&:full_text).join ""
|
|
61
61
|
end
|
|
62
62
|
|
|
@@ -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
|
|
@@ -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
|
|
@@ -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
|
|
@@ -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, property: 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
|
|
|
@@ -79,15 +79,20 @@ module NotionRubyMapping
|
|
|
79
79
|
objects = List.new(json: input_json, property: tmp, query: query).select { true }
|
|
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
|
|
|
@@ -70,8 +70,10 @@ 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
|
|
@@ -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
|
|
@@ -3,24 +3,47 @@
|
|
|
3
3
|
module NotionRubyMapping
|
|
4
4
|
# Status property
|
|
5
5
|
class StatusProperty < Property
|
|
6
|
+
include EqualsDoesNotEqual
|
|
7
|
+
include IsEmptyIsNotEmpty
|
|
6
8
|
TYPE = "status"
|
|
7
9
|
|
|
8
10
|
### Public announced methods
|
|
9
11
|
|
|
10
12
|
## Common methods
|
|
11
13
|
|
|
14
|
+
# @see https://www.notion.so/hkob/StatusProperty-c8b2c83019bc42edbc1527386c7ef453#bdb34c0aeaa74729887da087d0bd8022
|
|
12
15
|
def status
|
|
13
16
|
@json
|
|
14
17
|
end
|
|
15
18
|
|
|
19
|
+
## Page property only methods
|
|
20
|
+
|
|
21
|
+
# @return [String]
|
|
22
|
+
# @see https://www.notion.so/hkob/StatusProperty-c8b2c83019bc42edbc1527386c7ef453#69452ceee6c9452296e96bb2a37460ee
|
|
23
|
+
def status_name
|
|
24
|
+
assert_page_property __method__
|
|
25
|
+
@json["name"]
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
## Page property only methods
|
|
29
|
+
|
|
30
|
+
# @param [String] status
|
|
31
|
+
# @see https://www.notion.so/hkob/StatusProperty-c8b2c83019bc42edbc1527386c7ef453#b3fba1b6322140f28308de3ba70a8b7b
|
|
32
|
+
def status=(status)
|
|
33
|
+
assert_page_property __method__
|
|
34
|
+
@will_update = true
|
|
35
|
+
@json = {"name" => status}
|
|
36
|
+
end
|
|
37
|
+
|
|
16
38
|
### Not public announced methods
|
|
17
39
|
|
|
18
40
|
## Common methods
|
|
19
41
|
|
|
20
42
|
# @param [String] name Property name
|
|
21
43
|
# @param [Boolean, Hash] json
|
|
22
|
-
def initialize(name, will_update: false, base_type: :page, property_cache: nil, json: {})
|
|
23
|
-
super name, will_update: will_update, base_type: base_type,
|
|
44
|
+
def initialize(name, will_update: false, base_type: :page, property_id: nil, property_cache: nil, json: {})
|
|
45
|
+
super name, will_update: will_update, base_type: base_type, property_id: property_id,
|
|
46
|
+
property_cache: property_cache
|
|
24
47
|
@json = json
|
|
25
48
|
end
|
|
26
49
|
|
|
@@ -29,8 +52,7 @@ module NotionRubyMapping
|
|
|
29
52
|
# @return [Hash]
|
|
30
53
|
def property_values_json
|
|
31
54
|
assert_page_property __method__
|
|
32
|
-
{}
|
|
33
|
-
#{@name => {"status" => @json, "type" => "status"}}
|
|
55
|
+
{@name => {"status" => @json, "type" => "status"}}
|
|
34
56
|
end
|
|
35
57
|
end
|
|
36
58
|
end
|
|
@@ -27,10 +27,12 @@ module NotionRubyMapping
|
|
|
27
27
|
# @param [String] name
|
|
28
28
|
# @param [Hash, Array] json
|
|
29
29
|
# @param [Array<RichTextObject>] text_objects
|
|
30
|
-
def initialize(name, will_update: false, base_type: :page, json: nil, text_objects: nil,
|
|
30
|
+
def initialize(name, will_update: false, base_type: :page, json: nil, text_objects: nil, property_id: nil,
|
|
31
|
+
property_cache: nil, query: nil)
|
|
31
32
|
raise StandardError, "TextObject is abstract class. Please use RichTextProperty." if instance_of? TextProperty
|
|
32
33
|
|
|
33
|
-
super name, will_update: will_update, base_type: base_type,
|
|
34
|
+
super name, will_update: will_update, base_type: base_type, property_id: property_id,
|
|
35
|
+
property_cache: property_cache, query: query
|
|
34
36
|
@text_objects = if database?
|
|
35
37
|
json || {}
|
|
36
38
|
else
|
|
@@ -10,8 +10,12 @@ module NotionRubyMapping
|
|
|
10
10
|
## Common methods
|
|
11
11
|
|
|
12
12
|
def self.rich_text_array_from_json(json)
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
if json["object"] == "list"
|
|
14
|
+
rich_text_objects = List.new(json: json, property: self).select { true }
|
|
15
|
+
RichTextArray.rich_text_array "title", rich_text_objects
|
|
16
|
+
else
|
|
17
|
+
RichTextArray.new "title", json: json["title"]
|
|
18
|
+
end
|
|
15
19
|
end
|
|
16
20
|
|
|
17
21
|
# @param [Hash] json
|
|
@@ -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 = json || (database? ? {} : nil)
|
|
40
41
|
end
|
|
41
42
|
|
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.6.
|
|
4
|
+
version: 0.6.7
|
|
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-09-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|