notion_ruby_mapping 0.2.1 → 0.3.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 +500 -141
- data/env.yml.sample +2 -0
- data/examples/change_title.md +26 -0
- data/examples/renumbering_pages.md +20 -0
- data/examples/set_icon_to_all_icon_unsettled_pages.md +30 -0
- data/lib/notion_ruby_mapping/base.rb +130 -73
- data/lib/notion_ruby_mapping/checkbox_property.rb +27 -12
- data/lib/notion_ruby_mapping/created_by_property.rb +22 -10
- data/lib/notion_ruby_mapping/created_time_property.rb +16 -14
- data/lib/notion_ruby_mapping/database.rb +78 -8
- data/lib/notion_ruby_mapping/date_property.rb +67 -42
- data/lib/notion_ruby_mapping/email_property.rb +26 -16
- data/lib/notion_ruby_mapping/files_property.rb +40 -24
- data/lib/notion_ruby_mapping/formula_property.rb +51 -10
- data/lib/notion_ruby_mapping/last_edited_by_property.rb +22 -9
- data/lib/notion_ruby_mapping/last_edited_time_property.rb +16 -14
- data/lib/notion_ruby_mapping/list.rb +27 -19
- data/lib/notion_ruby_mapping/mention_object.rb +26 -1
- data/lib/notion_ruby_mapping/multi_select_property.rb +83 -21
- data/lib/notion_ruby_mapping/notion_cache.rb +25 -10
- data/lib/notion_ruby_mapping/number_property.rb +71 -10
- data/lib/notion_ruby_mapping/page.rb +33 -5
- data/lib/notion_ruby_mapping/payload.rb +23 -5
- data/lib/notion_ruby_mapping/people_property.rb +47 -19
- data/lib/notion_ruby_mapping/phone_number_property.rb +26 -15
- data/lib/notion_ruby_mapping/property.rb +140 -49
- data/lib/notion_ruby_mapping/property_cache.rb +31 -3
- data/lib/notion_ruby_mapping/query.rb +10 -0
- data/lib/notion_ruby_mapping/relation_property.rb +74 -21
- data/lib/notion_ruby_mapping/rich_text_array.rb +81 -0
- data/lib/notion_ruby_mapping/rich_text_object.rb +58 -1
- data/lib/notion_ruby_mapping/rich_text_property.rb +12 -1
- data/lib/notion_ruby_mapping/rollup_property.rb +82 -10
- data/lib/notion_ruby_mapping/select_property.rb +88 -13
- data/lib/notion_ruby_mapping/text_object.rb +0 -51
- data/lib/notion_ruby_mapping/text_property.rb +19 -45
- data/lib/notion_ruby_mapping/title_property.rb +12 -1
- data/lib/notion_ruby_mapping/url_property.rb +26 -15
- data/lib/notion_ruby_mapping/user_object.rb +4 -4
- data/lib/notion_ruby_mapping/version.rb +1 -1
- data/lib/notion_ruby_mapping.rb +2 -1
- data/tools/an +103 -0
- metadata +7 -2
@@ -36,16 +36,27 @@ module NotionRubyMapping
|
|
36
36
|
|
37
37
|
### create path methods
|
38
38
|
|
39
|
+
# @param [String] database_id
|
40
|
+
# @return [String (frozen)] page_path
|
41
|
+
def database_path(database_id)
|
42
|
+
"v1/databases/#{database_id}"
|
43
|
+
end
|
44
|
+
|
45
|
+
# @param [String] database_id
|
46
|
+
# @return [String (frozen)] page_path
|
47
|
+
def databases_path
|
48
|
+
"v1/databases"
|
49
|
+
end
|
50
|
+
|
39
51
|
# @param [String] page_id
|
40
52
|
# @return [String (frozen)] page_path
|
41
53
|
def page_path(page_id)
|
42
54
|
"v1/pages/#{page_id}"
|
43
55
|
end
|
44
56
|
|
45
|
-
# @param [String] database_id
|
46
57
|
# @return [String (frozen)] page_path
|
47
|
-
def
|
48
|
-
"v1/
|
58
|
+
def pages_path
|
59
|
+
"v1/pages"
|
49
60
|
end
|
50
61
|
|
51
62
|
# @param [String] block_id
|
@@ -124,6 +135,16 @@ module NotionRubyMapping
|
|
124
135
|
request :patch, "v1/pages/#{page_id}", payload
|
125
136
|
end
|
126
137
|
|
138
|
+
# @param [Hash] payload
|
139
|
+
# @return [Hash] response
|
140
|
+
def create_page_request(payload)
|
141
|
+
request :post, "v1/pages", payload
|
142
|
+
end
|
143
|
+
|
144
|
+
def create_database_request(payload)
|
145
|
+
request :post, databases_path, payload
|
146
|
+
end
|
147
|
+
|
127
148
|
# @param [String] id id string with "-"
|
128
149
|
# @return [String] id without "-"
|
129
150
|
def hex_id(id)
|
@@ -173,13 +194,7 @@ module NotionRubyMapping
|
|
173
194
|
# @param [NotionRubyMapping::Query] query query object
|
174
195
|
# @return [NotionRubyMapping::Base] List object
|
175
196
|
def database_query(id, query)
|
176
|
-
|
177
|
-
parameters[:filter] = query.filter unless query.filter.empty?
|
178
|
-
parameters[:sorts] = query.sort unless query.sort.empty?
|
179
|
-
parameters[:start_cursor] = query.start_cursor if query.start_cursor
|
180
|
-
parameters[:page_size] = query.page_size if query.page_size
|
181
|
-
|
182
|
-
Base.create_from_json database_query_request(id, parameters)
|
197
|
+
Base.create_from_json database_query_request(id, query.query_json)
|
183
198
|
end
|
184
199
|
|
185
200
|
# @param [String] id page_id (with or without "-")
|
@@ -8,28 +8,89 @@ module NotionRubyMapping
|
|
8
8
|
include IsEmptyIsNotEmpty
|
9
9
|
TYPE = "number"
|
10
10
|
|
11
|
+
### Public announced methods
|
12
|
+
|
13
|
+
## Common methods
|
14
|
+
|
15
|
+
# @return [Numeric, Hash]
|
16
|
+
def number
|
17
|
+
@json
|
18
|
+
end
|
19
|
+
|
20
|
+
## Database property only methods
|
21
|
+
|
22
|
+
# @return [String] new or settled format
|
23
|
+
def format
|
24
|
+
assert_database_property __method__
|
25
|
+
@json["format"]
|
26
|
+
end
|
27
|
+
|
28
|
+
# @param [String] format
|
29
|
+
# @return [String] settled format
|
30
|
+
def format=(format)
|
31
|
+
assert_database_property __method__
|
32
|
+
@will_update = true
|
33
|
+
@json["format"] = format
|
34
|
+
end
|
35
|
+
|
36
|
+
## Page property only methods
|
37
|
+
|
38
|
+
# @param [Numeric] num
|
39
|
+
# @return [Numeric] settled number
|
40
|
+
def number=(num)
|
41
|
+
assert_page_property __method__
|
42
|
+
@will_update = true
|
43
|
+
@json = num
|
44
|
+
end
|
45
|
+
|
46
|
+
### Not public announced methods
|
47
|
+
|
48
|
+
## Common methods
|
49
|
+
|
11
50
|
# @param [String] name Property name
|
12
|
-
# @param [Float, Integer]
|
13
|
-
def initialize(name, will_update: false,
|
14
|
-
super name, will_update: will_update
|
15
|
-
@
|
51
|
+
# @param [Float, Integer, Hash] json Number value or format Hash
|
52
|
+
def initialize(name, will_update: false, base_type: :page, json: nil, format: nil)
|
53
|
+
super name, will_update: will_update, base_type: base_type
|
54
|
+
@json = json
|
55
|
+
@json ||= {"format" => (format || "number")} if database?
|
16
56
|
end
|
17
|
-
attr_reader :number
|
18
57
|
|
19
58
|
# @param [Hash] json
|
59
|
+
# @return [NotionRubyMapping::NumberProperty]
|
20
60
|
def update_from_json(json)
|
21
61
|
@will_update = false
|
22
|
-
@
|
62
|
+
@json = json["number"]
|
63
|
+
self
|
64
|
+
end
|
65
|
+
|
66
|
+
## Database property only methods
|
67
|
+
|
68
|
+
# @return [Hash]
|
69
|
+
def update_property_schema_json
|
70
|
+
assert_database_property __method__
|
71
|
+
ans = super
|
72
|
+
return ans if ans != {} || !@will_update
|
73
|
+
|
74
|
+
ans[@name] ||= {}
|
75
|
+
ans[@name]["number"] = @json
|
76
|
+
ans
|
23
77
|
end
|
24
78
|
|
79
|
+
## Page property only methods
|
80
|
+
|
25
81
|
# @return [Hash]
|
26
82
|
def property_values_json
|
27
|
-
|
83
|
+
assert_page_property __method__
|
84
|
+
{@name => {"number" => @json, "type" => "number"}}
|
28
85
|
end
|
29
86
|
|
30
|
-
|
31
|
-
|
32
|
-
|
87
|
+
protected
|
88
|
+
|
89
|
+
## Database property only methods
|
90
|
+
|
91
|
+
# @return [Hash]
|
92
|
+
def property_schema_json_sub
|
93
|
+
{"format" => format}
|
33
94
|
end
|
34
95
|
end
|
35
96
|
end
|
@@ -3,20 +3,48 @@
|
|
3
3
|
module NotionRubyMapping
|
4
4
|
# Notion page object
|
5
5
|
class Page < Base
|
6
|
-
|
7
|
-
|
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
|
8
17
|
end
|
9
18
|
|
10
|
-
|
11
|
-
|
12
|
-
|
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}
|
13
22
|
end
|
14
23
|
|
15
24
|
protected
|
16
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
|
+
|
17
36
|
# @return [Hash]
|
18
37
|
def reload_json
|
19
38
|
@nc.page_request @id
|
20
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
|
21
49
|
end
|
22
50
|
end
|
@@ -3,8 +3,8 @@
|
|
3
3
|
module NotionRubyMapping
|
4
4
|
# Payload class
|
5
5
|
class Payload
|
6
|
-
def initialize
|
7
|
-
@json = {}
|
6
|
+
def initialize(json)
|
7
|
+
@json = json || {}
|
8
8
|
end
|
9
9
|
|
10
10
|
# @param [String] emoji
|
@@ -22,10 +22,28 @@ module NotionRubyMapping
|
|
22
22
|
self
|
23
23
|
end
|
24
24
|
|
25
|
+
# @param [Hash] json
|
26
|
+
def merge_property(json)
|
27
|
+
@json["properties"] ||= {}
|
28
|
+
@json["properties"].merge!(json)
|
29
|
+
end
|
30
|
+
|
31
|
+
# @return [Hash] created json
|
32
|
+
# @param [Object] others
|
33
|
+
def property_values_json(*others)
|
34
|
+
others.compact.reduce({}) { |hash, o| hash.merge o.property_values_json }.merge @json
|
35
|
+
end
|
36
|
+
|
37
|
+
# @return [Hash] created json
|
38
|
+
# @param [Object] others
|
39
|
+
def property_schema_json(*others)
|
40
|
+
others.compact.reduce({}) { |hash, o| hash.merge o.property_schema_json }.merge @json
|
41
|
+
end
|
42
|
+
|
25
43
|
# @return [Hash] created json
|
26
|
-
# @param [
|
27
|
-
def
|
28
|
-
|
44
|
+
# @param [Object] others
|
45
|
+
def update_property_schema_json(*others)
|
46
|
+
others.compact.reduce({}) { |hash, o| hash.merge o.update_property_schema_json }.merge @json
|
29
47
|
end
|
30
48
|
|
31
49
|
# @return [Hash] {}
|
@@ -5,41 +5,69 @@ module NotionRubyMapping
|
|
5
5
|
class PeopleProperty < MultiProperty
|
6
6
|
TYPE = "people"
|
7
7
|
|
8
|
+
### Public announced methods
|
9
|
+
|
10
|
+
## Common methods
|
11
|
+
|
12
|
+
# @return [Array, Hash]
|
13
|
+
def people
|
14
|
+
@json
|
15
|
+
end
|
16
|
+
|
17
|
+
## Page property only methods
|
18
|
+
|
19
|
+
# @param [String, NotionRubyMapping::UserObject] user_or_user_id
|
20
|
+
# @return [Array<UserObject>]
|
21
|
+
def add_person(user_or_user_id)
|
22
|
+
@will_update = true
|
23
|
+
@json << UserObject.user_object(user_or_user_id)
|
24
|
+
end
|
25
|
+
|
26
|
+
# @param [Hash] people
|
27
|
+
# @return [Array, nil] replaced array
|
28
|
+
def people=(people)
|
29
|
+
@will_update = true
|
30
|
+
@json = people ? Array(people).map { |uo| UserObject.user_object(uo) } : []
|
31
|
+
end
|
32
|
+
|
33
|
+
### Not public announced methods
|
34
|
+
|
35
|
+
## Common methods
|
36
|
+
|
8
37
|
# @param [String] name
|
9
38
|
# @param [Hash] json
|
10
39
|
# @param [Array] people ids for people
|
11
|
-
def initialize(name, will_update: false, json: nil, people: nil)
|
12
|
-
super name, will_update: will_update
|
13
|
-
@
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
40
|
+
def initialize(name, will_update: false, base_type: :page, json: nil, people: nil)
|
41
|
+
super name, will_update: will_update, base_type: base_type
|
42
|
+
@json = if database?
|
43
|
+
{}
|
44
|
+
elsif people
|
45
|
+
Array(people).map { |uo| UserObject.user_object(uo) }
|
46
|
+
elsif json
|
47
|
+
json.map { |p| UserObject.new json: p }
|
48
|
+
else
|
49
|
+
[]
|
50
|
+
end
|
20
51
|
end
|
21
52
|
|
53
|
+
## Page property only methods
|
54
|
+
|
22
55
|
# @return [Hash] created json
|
23
56
|
def property_values_json
|
57
|
+
assert_page_property __method__
|
24
58
|
{
|
25
59
|
@name => {
|
26
60
|
"type" => "people",
|
27
|
-
"people" => @
|
61
|
+
"people" => @json.map(&:property_values_json),
|
28
62
|
},
|
29
63
|
}
|
30
64
|
end
|
31
65
|
|
32
|
-
# @param [
|
66
|
+
# @param [Array] json
|
67
|
+
# @return [Hash, Array]
|
33
68
|
def update_from_json(json)
|
34
69
|
@will_update = false
|
35
|
-
@
|
36
|
-
end
|
37
|
-
|
38
|
-
# @param [Hash] people
|
39
|
-
# @return [Array, nil] settled array
|
40
|
-
def people=(people)
|
41
|
-
@will_update = true
|
42
|
-
@people = people ? Array(people).map { |uo| UserObject.user_object(uo) } : []
|
70
|
+
@json = database? ? {} : json["people"].map { |p_json| UserObject.new json: p_json }
|
43
71
|
end
|
44
72
|
end
|
45
73
|
end
|
@@ -9,28 +9,39 @@ module NotionRubyMapping
|
|
9
9
|
include IsEmptyIsNotEmpty
|
10
10
|
TYPE = "phone_number"
|
11
11
|
|
12
|
+
### Public announced methods
|
13
|
+
|
14
|
+
## Common methods
|
15
|
+
|
16
|
+
# @return [String, Hash, nil] phone number (Page), {} (Database)
|
17
|
+
def phone_number
|
18
|
+
@json
|
19
|
+
end
|
20
|
+
|
21
|
+
## Page property only methods
|
22
|
+
|
23
|
+
def phone_number=(phone_number)
|
24
|
+
@will_update = true
|
25
|
+
@json = phone_number
|
26
|
+
end
|
27
|
+
|
28
|
+
### Not public announced methods
|
29
|
+
|
30
|
+
## Common methods
|
31
|
+
|
12
32
|
# @param [String] name Property name
|
13
33
|
# @param [String] phone_number phone_number value (optional)
|
14
|
-
def initialize(name, will_update: false,
|
15
|
-
super name, will_update: will_update
|
16
|
-
@
|
34
|
+
def initialize(name, will_update: false, base_type: :page, json: nil)
|
35
|
+
super name, will_update: will_update, base_type: base_type
|
36
|
+
@json = database? ? {} : json
|
17
37
|
end
|
18
|
-
attr_reader :phone_number
|
19
38
|
|
20
|
-
|
21
|
-
def update_from_json(json)
|
22
|
-
@will_update = false
|
23
|
-
@phone_number = json["phone_number"]
|
24
|
-
end
|
39
|
+
## Page property only methods
|
25
40
|
|
26
41
|
# @return [Hash]
|
27
42
|
def property_values_json
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
def phone_number=(phone_number)
|
32
|
-
@will_update = true
|
33
|
-
@phone_number = phone_number
|
43
|
+
assert_page_property __method__
|
44
|
+
{@name => {"phone_number" => @json, "type" => "phone_number"}}
|
34
45
|
end
|
35
46
|
end
|
36
47
|
end
|
@@ -3,16 +3,87 @@
|
|
3
3
|
module NotionRubyMapping
|
4
4
|
# abstract class for property
|
5
5
|
class Property
|
6
|
+
### Public announced methods
|
7
|
+
|
8
|
+
## Common methods
|
9
|
+
|
10
|
+
attr_reader :name, :will_update
|
11
|
+
|
12
|
+
## Database property only methods
|
13
|
+
|
14
|
+
# @param [String] new_name
|
15
|
+
def new_name=(new_name)
|
16
|
+
assert_database_property __method__
|
17
|
+
@will_update = true
|
18
|
+
@new_name = new_name
|
19
|
+
end
|
20
|
+
|
21
|
+
# @return [NotionRubyMapping::Property] self
|
22
|
+
def remove
|
23
|
+
assert_database_property __method__
|
24
|
+
@will_update = true
|
25
|
+
@remove = true
|
26
|
+
self
|
27
|
+
end
|
28
|
+
|
29
|
+
### Not public announced methods
|
30
|
+
|
31
|
+
## Common methods
|
32
|
+
|
6
33
|
# @param [String] name Property name
|
7
34
|
# @return [Property] generated Property object
|
8
|
-
def initialize(name, will_update: false)
|
35
|
+
def initialize(name, will_update: false, base_type: :page)
|
9
36
|
@name = name
|
10
37
|
@will_update = will_update
|
38
|
+
@base_type = base_type
|
39
|
+
@create = false
|
40
|
+
@remove = false
|
41
|
+
@new_name = nil
|
42
|
+
@json = nil
|
43
|
+
end
|
44
|
+
|
45
|
+
# @param [String] name
|
46
|
+
# @param [Hash] input_json
|
47
|
+
# @return [NotionRubyMapping::Property, nil] generated Property object
|
48
|
+
def self.create_from_json(name, input_json, base_type = :page)
|
49
|
+
raise StandardError, "Property not found: #{name}:#{input_json}" if input_json.nil?
|
50
|
+
|
51
|
+
type = input_json["type"]
|
52
|
+
klass = {
|
53
|
+
"checkbox" => CheckboxProperty,
|
54
|
+
"created_time" => CreatedTimeProperty,
|
55
|
+
"date" => DateProperty,
|
56
|
+
"formula" => FormulaProperty,
|
57
|
+
"last_edited_time" => LastEditedTimeProperty,
|
58
|
+
"rollup" => RollupProperty,
|
59
|
+
"email" => EmailProperty,
|
60
|
+
"files" => FilesProperty,
|
61
|
+
"created_by" => CreatedByProperty,
|
62
|
+
"last_edited_by" => LastEditedByProperty,
|
63
|
+
"multi_select" => MultiSelectProperty,
|
64
|
+
"people" => PeopleProperty,
|
65
|
+
"relation" => RelationProperty,
|
66
|
+
"number" => NumberProperty,
|
67
|
+
"phone_number" => PhoneNumberProperty,
|
68
|
+
"select" => SelectProperty,
|
69
|
+
"title" => TitleProperty,
|
70
|
+
"rich_text" => RichTextProperty,
|
71
|
+
"url" => UrlProperty,
|
72
|
+
}[type]
|
73
|
+
raise StandardError, "Irregular property type: #{type}" unless klass
|
74
|
+
|
75
|
+
klass.new name, json: input_json[type], base_type: base_type
|
11
76
|
end
|
12
|
-
attr_reader :name
|
13
77
|
|
14
|
-
# @return [
|
15
|
-
|
78
|
+
# @return [FalseClass]
|
79
|
+
def clear_will_update
|
80
|
+
@will_update = false
|
81
|
+
end
|
82
|
+
|
83
|
+
# @return [TrueClass, FalseClass] true if database property
|
84
|
+
def database?
|
85
|
+
@base_type == :database
|
86
|
+
end
|
16
87
|
|
17
88
|
# @param [String] key query parameter
|
18
89
|
# @param [Object] value query value
|
@@ -25,64 +96,76 @@ module NotionRubyMapping
|
|
25
96
|
end
|
26
97
|
end
|
27
98
|
|
99
|
+
# @return [TrueClass, FalseClass] true if page property
|
100
|
+
def page?
|
101
|
+
@base_type == :page
|
102
|
+
end
|
103
|
+
|
104
|
+
# @param [Hash] json
|
105
|
+
def update_from_json(json)
|
106
|
+
@will_update = false
|
107
|
+
@json = json[type]
|
108
|
+
end
|
109
|
+
|
28
110
|
# @return [Symbol] property type
|
29
111
|
def type
|
30
112
|
self.class::TYPE
|
31
113
|
end
|
32
114
|
|
33
|
-
|
34
|
-
|
35
|
-
# @
|
36
|
-
def
|
37
|
-
raise StandardError, "
|
115
|
+
## Database property only methods
|
116
|
+
|
117
|
+
# @param [Symbol, nil] method
|
118
|
+
def assert_database_property(method)
|
119
|
+
raise StandardError, "#{method} can execute only Database property." unless database?
|
120
|
+
end
|
121
|
+
|
122
|
+
# @return [Hash]
|
123
|
+
def property_schema_json
|
124
|
+
assert_database_property __method__
|
125
|
+
{@name => {type => property_schema_json_sub}}
|
126
|
+
end
|
38
127
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
when "date"
|
47
|
-
DateProperty.new name, json: input_json["date"]
|
48
|
-
when "title"
|
49
|
-
TitleProperty.new name, json: input_json["title"]
|
50
|
-
when "rich_text"
|
51
|
-
RichTextProperty.new name, json: input_json["rich_text"]
|
52
|
-
when "checkbox"
|
53
|
-
CheckboxProperty.new name, checkbox: input_json["checkbox"]
|
54
|
-
when "people"
|
55
|
-
PeopleProperty.new name, json: input_json["people"]
|
56
|
-
when "email"
|
57
|
-
EmailProperty.new name, email: input_json["email"]
|
58
|
-
when "url"
|
59
|
-
UrlProperty.new name, url: input_json["url"]
|
60
|
-
when "phone_number"
|
61
|
-
PhoneNumberProperty.new name, phone_number: input_json["phone_number"]
|
62
|
-
when "files"
|
63
|
-
FilesProperty.new name, json: input_json["files"]
|
64
|
-
when "created_time"
|
65
|
-
CreatedTimeProperty.new name, created_time: input_json["created_time"]
|
66
|
-
when "last_edited_time"
|
67
|
-
LastEditedTimeProperty.new name, last_edited_time: input_json["last_edited_time"]
|
68
|
-
when "created_by"
|
69
|
-
CreatedByProperty.new name, json: input_json["created_by"]
|
70
|
-
when "last_edited_by"
|
71
|
-
LastEditedByProperty.new name, json: input_json["last_edited_by"]
|
72
|
-
when "formula"
|
73
|
-
FormulaProperty.new name, json: input_json["formula"]
|
74
|
-
when "rollup"
|
75
|
-
RollupProperty.new name, json: input_json["rollup"]
|
76
|
-
when "relation"
|
77
|
-
RelationProperty.new name, json: input_json["relation"]
|
128
|
+
# @return [Hash]
|
129
|
+
def update_property_schema_json
|
130
|
+
assert_database_property __method__
|
131
|
+
if @remove
|
132
|
+
{@name => nil}
|
133
|
+
elsif @new_name
|
134
|
+
{@name => {"name" => @new_name}}
|
78
135
|
else
|
79
|
-
|
136
|
+
{}
|
80
137
|
end
|
81
138
|
end
|
139
|
+
|
140
|
+
## Page property only methods
|
141
|
+
|
142
|
+
# @param [Symbol, nil] method
|
143
|
+
def assert_page_property(method)
|
144
|
+
raise StandardError, "#{method} can execute only Page property." unless @base_type == :page
|
145
|
+
end
|
146
|
+
|
147
|
+
## Page property only methods
|
148
|
+
|
149
|
+
# @return [Hash] {} created_time cannot be updated
|
150
|
+
def property_values_json
|
151
|
+
assert_page_property __method__
|
152
|
+
{}
|
153
|
+
end
|
154
|
+
|
155
|
+
protected
|
156
|
+
|
157
|
+
## Database property only methods
|
158
|
+
|
159
|
+
# @return [Hash]
|
160
|
+
def property_schema_json_sub
|
161
|
+
{}
|
162
|
+
end
|
82
163
|
end
|
83
164
|
|
84
165
|
# module for make query of equals and does_not_equal
|
85
166
|
module EqualsDoesNotEqual
|
167
|
+
### Public announced methods
|
168
|
+
|
86
169
|
# @param [String, Number] value Query value
|
87
170
|
# @return [NotionRubyMapping::Query] generated Query object
|
88
171
|
def filter_equals(value, rollup = nil, rollup_type = nil)
|
@@ -98,6 +181,8 @@ module NotionRubyMapping
|
|
98
181
|
|
99
182
|
# module for make query of contains and does_not_contain
|
100
183
|
module ContainsDoesNotContain
|
184
|
+
### Public announced methods
|
185
|
+
|
101
186
|
# @param [String] value Query value
|
102
187
|
# @return [NotionRubyMapping::Query] generated Query object
|
103
188
|
def filter_contains(value, rollup = nil, rollup_type = nil)
|
@@ -113,6 +198,8 @@ module NotionRubyMapping
|
|
113
198
|
|
114
199
|
# module for make query of starts_with and ends_with
|
115
200
|
module StartsWithEndsWith
|
201
|
+
### Public announced methods
|
202
|
+
|
116
203
|
# @param [String] value Query value
|
117
204
|
# @return [NotionRubyMapping::Query] generated Query object
|
118
205
|
def filter_starts_with(value, rollup = nil, rollup_type = nil)
|
@@ -128,6 +215,8 @@ module NotionRubyMapping
|
|
128
215
|
|
129
216
|
# module for make query of is_empty and is_not_empty
|
130
217
|
module IsEmptyIsNotEmpty
|
218
|
+
### Public announced methods
|
219
|
+
|
131
220
|
# @return [NotionRubyMapping::Query] generated Query object
|
132
221
|
def filter_is_empty(rollup = nil, rollup_type = nil)
|
133
222
|
make_filter_query "is_empty", true, rollup, rollup_type
|
@@ -141,6 +230,8 @@ module NotionRubyMapping
|
|
141
230
|
|
142
231
|
# module for make query of starts_with and ends_with
|
143
232
|
module GreaterThanLessThan
|
233
|
+
### Public announced methods
|
234
|
+
|
144
235
|
# @param [Number] value Query value
|
145
236
|
# @return [NotionRubyMapping::Query] generated Query object
|
146
237
|
def filter_greater_than(value, rollup = nil, rollup_type = nil)
|