notion_ruby_mapping 1.0.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/lib/notion_ruby_mapping/blocks/base.rb +51 -37
  3. data/lib/notion_ruby_mapping/blocks/block.rb +13 -13
  4. data/lib/notion_ruby_mapping/blocks/bookmark_block.rb +1 -1
  5. data/lib/notion_ruby_mapping/blocks/breadcrumb_block.rb +1 -1
  6. data/lib/notion_ruby_mapping/blocks/bulleted_list_item_block.rb +1 -1
  7. data/lib/notion_ruby_mapping/blocks/callout_block.rb +10 -10
  8. data/lib/notion_ruby_mapping/blocks/child_base_block.rb +2 -2
  9. data/lib/notion_ruby_mapping/blocks/child_database_block.rb +3 -3
  10. data/lib/notion_ruby_mapping/blocks/child_page_block.rb +3 -3
  11. data/lib/notion_ruby_mapping/blocks/code_block.rb +7 -7
  12. data/lib/notion_ruby_mapping/blocks/column_block.rb +3 -3
  13. data/lib/notion_ruby_mapping/blocks/column_list_block.rb +2 -2
  14. data/lib/notion_ruby_mapping/blocks/database.rb +5 -5
  15. data/lib/notion_ruby_mapping/blocks/divider_block.rb +1 -1
  16. data/lib/notion_ruby_mapping/blocks/embed_block.rb +2 -2
  17. data/lib/notion_ruby_mapping/blocks/equation_block.rb +5 -5
  18. data/lib/notion_ruby_mapping/blocks/file_base_block.rb +15 -3
  19. data/lib/notion_ruby_mapping/blocks/file_block.rb +2 -2
  20. data/lib/notion_ruby_mapping/blocks/heading1_block.rb +3 -3
  21. data/lib/notion_ruby_mapping/blocks/heading2_block.rb +2 -2
  22. data/lib/notion_ruby_mapping/blocks/heading3_block.rb +3 -3
  23. data/lib/notion_ruby_mapping/blocks/image_block.rb +2 -2
  24. data/lib/notion_ruby_mapping/blocks/link_preview_block.rb +2 -2
  25. data/lib/notion_ruby_mapping/blocks/link_to_page_block.rb +5 -5
  26. data/lib/notion_ruby_mapping/blocks/list.rb +21 -21
  27. data/lib/notion_ruby_mapping/blocks/numbered_list_item_block.rb +2 -2
  28. data/lib/notion_ruby_mapping/blocks/page.rb +8 -8
  29. data/lib/notion_ruby_mapping/blocks/paragraph_block.rb +2 -2
  30. data/lib/notion_ruby_mapping/blocks/pdf_block.rb +2 -2
  31. data/lib/notion_ruby_mapping/blocks/quote_block.rb +1 -1
  32. data/lib/notion_ruby_mapping/blocks/synced_block.rb +5 -5
  33. data/lib/notion_ruby_mapping/blocks/table_block.rb +8 -8
  34. data/lib/notion_ruby_mapping/blocks/table_of_contents_block.rb +3 -3
  35. data/lib/notion_ruby_mapping/blocks/table_row_block.rb +3 -3
  36. data/lib/notion_ruby_mapping/blocks/template_block.rb +3 -3
  37. data/lib/notion_ruby_mapping/blocks/text_sub_block_color_base_block.rb +4 -4
  38. data/lib/notion_ruby_mapping/blocks/to_do_block.rb +4 -4
  39. data/lib/notion_ruby_mapping/blocks/toggle_block.rb +2 -2
  40. data/lib/notion_ruby_mapping/blocks/toggle_heading1_block.rb +2 -2
  41. data/lib/notion_ruby_mapping/blocks/toggle_heading2_block.rb +2 -2
  42. data/lib/notion_ruby_mapping/blocks/toggle_heading3_block.rb +3 -3
  43. data/lib/notion_ruby_mapping/blocks/url_base_block.rb +3 -3
  44. data/lib/notion_ruby_mapping/blocks/url_caption_base_block.rb +4 -4
  45. data/lib/notion_ruby_mapping/blocks/video_block.rb +2 -2
  46. data/lib/notion_ruby_mapping/controllers/mermaid.rb +2 -5
  47. data/lib/notion_ruby_mapping/controllers/mermaid_database.rb +29 -32
  48. data/lib/notion_ruby_mapping/controllers/notion_cache.rb +68 -2
  49. data/lib/notion_ruby_mapping/controllers/payload.rb +29 -11
  50. data/lib/notion_ruby_mapping/controllers/property_cache.rb +8 -9
  51. data/lib/notion_ruby_mapping/controllers/query.rb +14 -14
  52. data/lib/notion_ruby_mapping/controllers/search.rb +5 -5
  53. data/lib/notion_ruby_mapping/objects/comment_object.rb +2 -2
  54. data/lib/notion_ruby_mapping/objects/emoji_object.rb +3 -3
  55. data/lib/notion_ruby_mapping/objects/equation_object.rb +3 -3
  56. data/lib/notion_ruby_mapping/objects/file_object.rb +44 -21
  57. data/lib/notion_ruby_mapping/objects/file_upload_object.rb +78 -0
  58. data/lib/notion_ruby_mapping/objects/mention_object.rb +43 -43
  59. data/lib/notion_ruby_mapping/objects/rich_text_object.rb +43 -43
  60. data/lib/notion_ruby_mapping/objects/text_object.rb +5 -5
  61. data/lib/notion_ruby_mapping/objects/user_object.rb +4 -4
  62. data/lib/notion_ruby_mapping/properties/button_property.rb +3 -3
  63. data/lib/notion_ruby_mapping/properties/checkbox_property.rb +3 -3
  64. data/lib/notion_ruby_mapping/properties/created_by_property.rb +3 -3
  65. data/lib/notion_ruby_mapping/properties/created_time_property.rb +2 -2
  66. data/lib/notion_ruby_mapping/properties/date_base_property.rb +15 -14
  67. data/lib/notion_ruby_mapping/properties/date_property.rb +16 -16
  68. data/lib/notion_ruby_mapping/properties/email_property.rb +3 -3
  69. data/lib/notion_ruby_mapping/properties/files_property.rb +14 -12
  70. data/lib/notion_ruby_mapping/properties/formula_property.rb +7 -7
  71. data/lib/notion_ruby_mapping/properties/last_edited_by_property.rb +4 -3
  72. data/lib/notion_ruby_mapping/properties/last_edited_time_property.rb +2 -2
  73. data/lib/notion_ruby_mapping/properties/multi_select_property.rb +15 -15
  74. data/lib/notion_ruby_mapping/properties/number_property.rb +9 -9
  75. data/lib/notion_ruby_mapping/properties/people_property.rb +7 -7
  76. data/lib/notion_ruby_mapping/properties/phone_number_property.rb +3 -3
  77. data/lib/notion_ruby_mapping/properties/property.rb +55 -56
  78. data/lib/notion_ruby_mapping/properties/relation_property.rb +17 -18
  79. data/lib/notion_ruby_mapping/properties/rich_text_property.rb +5 -5
  80. data/lib/notion_ruby_mapping/properties/rollup_property.rb +15 -15
  81. data/lib/notion_ruby_mapping/properties/select_property.rb +14 -14
  82. data/lib/notion_ruby_mapping/properties/status_property.rb +5 -5
  83. data/lib/notion_ruby_mapping/properties/text_property.rb +1 -1
  84. data/lib/notion_ruby_mapping/properties/title_property.rb +7 -7
  85. data/lib/notion_ruby_mapping/properties/unique_id_property.rb +4 -4
  86. data/lib/notion_ruby_mapping/properties/url_property.rb +3 -3
  87. data/lib/notion_ruby_mapping/properties/verification_property.rb +3 -3
  88. data/lib/notion_ruby_mapping/version.rb +1 -1
  89. data/lib/notion_ruby_mapping.rb +1 -1
  90. data/notion_ruby_mapping.gemspec +2 -0
  91. metadata +35 -3
@@ -28,11 +28,11 @@ module NotionRubyMapping
28
28
 
29
29
  ## Database property only methods
30
30
 
31
- # @param [String, Symbol] new_name
31
+ # @param [String] new_name
32
32
  def new_name=(new_name)
33
33
  assert_database_property __method__
34
34
  @will_update = true
35
- @new_name = new_name.to_sym
35
+ @new_name = new_name
36
36
  end
37
37
 
38
38
  # @return [NotionRubyMapping::Property] self
@@ -49,8 +49,8 @@ module NotionRubyMapping
49
49
 
50
50
  # @param [String, Symbol] name Property name
51
51
  # @return [Property] generated Property object
52
- def initialize(name, will_update: false, base_type: :page, property_id: nil, property_cache: nil, query: nil)
53
- @name = name.to_sym
52
+ def initialize(name, will_update: false, base_type: "page", property_id: nil, property_cache: nil, query: nil)
53
+ @name = name
54
54
  @will_update = will_update
55
55
  @base_type = base_type
56
56
  @create = false
@@ -65,37 +65,36 @@ module NotionRubyMapping
65
65
  # @param [String, Symbol] name
66
66
  # @param [Hash] input_json
67
67
  # @return [NotionRubyMapping::Property, nil] generated Property object
68
- # @param [Symbol] base_type :page or :database
68
+ # @param [String] base_type "page" or "database"
69
69
  # @param [String, nil] page_id
70
- def self.create_from_json(name, input_json, base_type = :page, property_cache = nil, query = nil)
71
- name_sym = name.to_sym
72
- raise StandardError, "Property not found: #{name_sym}:#{input_json}" if input_json.nil?
70
+ def self.create_from_json(name, input_json, base_type = "page", property_cache = nil, query = nil)
71
+ raise StandardError, "Property not found: #{name}:#{input_json}" if input_json.nil?
73
72
 
74
- type = input_json[:type]&.to_sym
73
+ type = input_json["type"]
75
74
  if type.nil?
76
- new name_sym, property_id: input_json[:id], base_type: base_type, property_cache: property_cache, query: query
77
- elsif type == :property_item
78
- tmp = new name_sym, property_id: input_json[:property_item][:id], base_type: base_type,
79
- property_cache: property_cache, query: query
80
- objects = List.new(json: input_json, type: :property, value: tmp, query: query).to_a
81
- case input_json[:property_item][:type]&.to_sym
82
- when :people
83
- PeopleProperty.new name_sym, people: objects, base_type: base_type,
84
- property_cache: property_cache, query: query
85
- when :relation
86
- RelationProperty.new name_sym, relation: objects, base_type: base_type,
87
- property_cache: property_cache, query: query
88
- when :rich_text
89
- RichTextProperty.new name_sym, text_objects: objects, base_type: base_type,
90
- property_cache: property_cache, query: query
91
- when :rollup
92
- RollupProperty.new name_sym, json: objects, base_type: base_type,
93
- property_cache: property_cache, query: query
94
- when :title
95
- TitleProperty.new name_sym, text_objects: objects, base_type: base_type,
96
- property_cache: property_cache, query: query
75
+ new name, property_id: input_json["id"], base_type: base_type, property_cache: property_cache, query: query
76
+ elsif type == "property_item"
77
+ tmp = new name, property_id: input_json["property_item"]["id"], base_type: base_type,
78
+ property_cache: property_cache, query: query
79
+ objects = List.new(json: input_json, type: "property", value: tmp, query: query).to_a
80
+ case input_json["property_item"]["type"]
81
+ when "people"
82
+ PeopleProperty.new name, people: objects, base_type: base_type,
83
+ property_cache: property_cache, query: query
84
+ when "relation"
85
+ RelationProperty.new name, relation: objects, base_type: base_type,
86
+ property_cache: property_cache, query: query
87
+ when "rich_text"
88
+ RichTextProperty.new name, text_objects: objects, base_type: base_type,
89
+ property_cache: property_cache, query: query
90
+ when "rollup"
91
+ RollupProperty.new name, json: objects, base_type: base_type,
92
+ property_cache: property_cache, query: query
93
+ when "title"
94
+ TitleProperty.new name, text_objects: objects, base_type: base_type,
95
+ property_cache: property_cache, query: query
97
96
  else
98
- raise StandardError, "Irregular property type: #{input_json[:property_item][:type]}"
97
+ raise StandardError, "Irregular property type: #{input_json["property_item"]["type"]}"
99
98
  end
100
99
  else
101
100
  klass = {
@@ -122,12 +121,12 @@ module NotionRubyMapping
122
121
  unique_id: UniqueIdProperty,
123
122
  url: UrlProperty,
124
123
  verification: VerificationProperty,
125
- }[type]
124
+ }[type.to_sym]
126
125
  raise StandardError, "Irregular property type: #{type}" unless klass
127
126
 
128
- answer = klass.new name_sym, property_id: input_json[:id], json: input_json[type], base_type: base_type,
129
- property_cache: property_cache
130
- answer = answer.retrieve_page_property if answer.is_a?(RelationProperty) && input_json[:has_more] == true
127
+ answer = klass.new name, property_id: input_json["id"], json: input_json[type], base_type: base_type,
128
+ property_cache: property_cache
129
+ answer = answer.retrieve_page_property if answer.is_a?(RelationProperty) && input_json["has_more"] == true
131
130
  answer
132
131
  end
133
132
  end
@@ -141,7 +140,7 @@ module NotionRubyMapping
141
140
 
142
141
  # @return [TrueClass, FalseClass] true if database property
143
142
  def database?
144
- @base_type.to_sym == :database
143
+ @base_type == "database"
145
144
  end
146
145
 
147
146
  # @return [TrueClass, FalseClass] true if it has Property contents
@@ -154,19 +153,19 @@ module NotionRubyMapping
154
153
  # @return [NotionRubyMapping::Query] generated Query object
155
154
  def make_filter_query(key, value, condition: nil, another_type: nil)
156
155
  if condition
157
- Query.new filter: {property: @name, type => {condition => {another_type => {key => value}}}}
156
+ Query.new filter: {"property" => @name, type => {condition => {another_type => {key => value}}}}
158
157
  elsif another_type
159
- Query.new filter: {property: @name, type => {another_type => {key => value}}}
160
- elsif @name == :__timestamp__
161
- Query.new filter: {timestamp: type.to_s, type => {key => value}}
158
+ Query.new filter: {"property" => @name, type => {another_type => {key => value}}}
159
+ elsif @name == "__timestamp__"
160
+ Query.new filter: {"timestamp" => type.to_s, type => {key => value}}
162
161
  else
163
- Query.new filter: {property: @name, type => {key => value}}
162
+ Query.new filter: {"property" => @name, type => {key => value}}
164
163
  end
165
164
  end
166
165
 
167
166
  # @return [TrueClass, FalseClass] true if page property
168
167
  def page?
169
- @base_type == :page
168
+ @base_type == "page"
170
169
  end
171
170
 
172
171
  # @param [Hash] json
@@ -201,7 +200,7 @@ module NotionRubyMapping
201
200
  if @remove
202
201
  {@name => nil}
203
202
  elsif @new_name
204
- {@name => {name: @new_name}}
203
+ {@name => {"name" => @new_name}}
205
204
  else
206
205
  {}
207
206
  end
@@ -221,7 +220,7 @@ module NotionRubyMapping
221
220
 
222
221
  json = NotionCache.instance.page_property_request @property_cache.page_id, @property_id,
223
222
  (@query&.query_json || {})
224
- new_property = self.class.create_from_json @name, json, :page, @property_cache, @query
223
+ new_property = self.class.create_from_json @name, json, "page", @property_cache, @query
225
224
  @property_cache.add_property new_property
226
225
  new_property
227
226
  end
@@ -246,7 +245,7 @@ module NotionRubyMapping
246
245
  # @return [NotionRubyMapping::Query] generated Query object
247
246
  # @see https://www.notion.so/hkob/CheckboxProperty-ac1edbdb8e264af5ad1432b522b429fd#5f07c4ebc4744986bfc99a43827349fc
248
247
  def filter_equals(value, condition: nil, another_type: nil)
249
- make_filter_query :equals, value, condition: condition, another_type: another_type
248
+ make_filter_query "equals", value, condition: condition, another_type: another_type
250
249
  end
251
250
 
252
251
  # @param [String, Number] value Query value
@@ -255,7 +254,7 @@ module NotionRubyMapping
255
254
  # @return [NotionRubyMapping::Query] generated Query object
256
255
  # @see https://www.notion.so/hkob/CheckboxProperty-ac1edbdb8e264af5ad1432b522b429fd#a44a1875c3ef49f2b4f817291953a1d4
257
256
  def filter_does_not_equal(value, condition: nil, another_type: nil)
258
- make_filter_query :does_not_equal, value, condition: condition, another_type: another_type
257
+ make_filter_query "does_not_equal", value, condition: condition, another_type: another_type
259
258
  end
260
259
  end
261
260
 
@@ -269,7 +268,7 @@ module NotionRubyMapping
269
268
  # @return [NotionRubyMapping::Query] generated Query object
270
269
  # @see https://www.notion.so/hkob/CreatedByProperty-945fa6be1c014da2b7e55a2b76e37b57#271a2ebaa1ec48acae732ca98920feab
271
270
  def filter_contains(value, condition: nil, another_type: nil)
272
- make_filter_query :contains, value, condition: condition, another_type: another_type
271
+ make_filter_query "contains", value, condition: condition, another_type: another_type
273
272
  end
274
273
 
275
274
  # @param [String] value Query value
@@ -278,7 +277,7 @@ module NotionRubyMapping
278
277
  # @return [NotionRubyMapping::Query] generated Query object
279
278
  # @see https://www.notion.so/hkob/CreatedByProperty-945fa6be1c014da2b7e55a2b76e37b57#b0328e3b146f48a4ad4c9c2ee5363486
280
279
  def filter_does_not_contain(value, condition: nil, another_type: nil)
281
- make_filter_query :does_not_contain, value, condition: condition, another_type: another_type
280
+ make_filter_query "does_not_contain", value, condition: condition, another_type: another_type
282
281
  end
283
282
  end
284
283
 
@@ -292,7 +291,7 @@ module NotionRubyMapping
292
291
  # @return [NotionRubyMapping::Query] generated Query object
293
292
  # @see https://www.notion.so/hkob/EmailProperty-39aeb5df56ea4cc1b9380574e4fdeec0#d3e098b2f38c4c8c9d3e815516cfd953
294
293
  def filter_starts_with(value, condition: nil, another_type: nil)
295
- make_filter_query :starts_with, value, condition: condition, another_type: another_type
294
+ make_filter_query "starts_with", value, condition: condition, another_type: another_type
296
295
  end
297
296
 
298
297
  # @param [String] value Query value
@@ -300,7 +299,7 @@ module NotionRubyMapping
300
299
  # @param [String] rollup_type Rollup type
301
300
  # @return [NotionRubyMapping::Query] generated Query object
302
301
  def filter_ends_with(value, condition: nil, another_type: nil)
303
- make_filter_query :ends_with, value, condition: condition, another_type: another_type
302
+ make_filter_query "ends_with", value, condition: condition, another_type: another_type
304
303
  end
305
304
  end
306
305
 
@@ -313,7 +312,7 @@ module NotionRubyMapping
313
312
  # @return [NotionRubyMapping::Query] generated Query object
314
313
  # @see https://www.notion.so/hkob/CreatedByProperty-945fa6be1c014da2b7e55a2b76e37b57#38749dfae0854c68b4c55095d3efbff1
315
314
  def filter_is_empty(condition: nil, another_type: nil)
316
- make_filter_query :is_empty, true, condition: condition, another_type: another_type
315
+ make_filter_query "is_empty", true, condition: condition, another_type: another_type
317
316
  end
318
317
 
319
318
  # @param [String] rollup Rollup name
@@ -321,7 +320,7 @@ module NotionRubyMapping
321
320
  # @return [NotionRubyMapping::Query] generated Query object
322
321
  # @see https://www.notion.so/hkob/CreatedByProperty-945fa6be1c014da2b7e55a2b76e37b57#515659ea52b54fb48c81b813f3b705f6
323
322
  def filter_is_not_empty(condition: nil, another_type: nil)
324
- make_filter_query :is_not_empty, true, condition: condition, another_type: another_type
323
+ make_filter_query "is_not_empty", true, condition: condition, another_type: another_type
325
324
  end
326
325
  end
327
326
 
@@ -334,7 +333,7 @@ module NotionRubyMapping
334
333
  # @param [String] rollup_type Rollup type
335
334
  # @return [NotionRubyMapping::Query] generated Query object
336
335
  def filter_greater_than(value, condition: nil, another_type: nil)
337
- make_filter_query :greater_than, value, condition: condition, another_type: another_type
336
+ make_filter_query "greater_than", value, condition: condition, another_type: another_type
338
337
  end
339
338
 
340
339
  # @param [Number] value Query value
@@ -342,7 +341,7 @@ module NotionRubyMapping
342
341
  # @param [String] rollup_type Rollup type
343
342
  # @return [NotionRubyMapping::Query] generated Query object
344
343
  def filter_less_than(value, condition: nil, another_type: nil)
345
- make_filter_query :less_than, value, condition: condition, another_type: another_type
344
+ make_filter_query "less_than", value, condition: condition, another_type: another_type
346
345
  end
347
346
 
348
347
  # @param [Number] value Query value
@@ -350,7 +349,7 @@ module NotionRubyMapping
350
349
  # @param [String] rollup_type Rollup type
351
350
  # @return [NotionRubyMapping::Query] generated Query object
352
351
  def filter_greater_than_or_equal_to(value, condition: nil, another_type: nil)
353
- make_filter_query :greater_than_or_equal_to, value, condition: condition, another_type: another_type
352
+ make_filter_query "greater_than_or_equal_to", value, condition: condition, another_type: another_type
354
353
  end
355
354
 
356
355
  # @param [Number] value Query value
@@ -358,7 +357,7 @@ module NotionRubyMapping
358
357
  # @param [String] rollup_type Rollup type
359
358
  # @return [NotionRubyMapping::Query] generated Query object
360
359
  def filter_less_than_or_equal_to(value, condition: nil, another_type: nil)
361
- make_filter_query :less_than_or_equal_to, value, condition: condition, another_type: another_type
360
+ make_filter_query "less_than_or_equal_to", value, condition: condition, another_type: another_type
362
361
  end
363
362
  end
364
363
  end
@@ -3,7 +3,7 @@
3
3
  module NotionRubyMapping
4
4
  # MultiSelect property
5
5
  class RelationProperty < MultiProperty
6
- TYPE = :relation
6
+ TYPE = "relation"
7
7
 
8
8
  ### Public announced methods
9
9
 
@@ -23,7 +23,7 @@ module NotionRubyMapping
23
23
  assert_page_property __method__
24
24
  @will_update = true
25
25
  @json << if page_id_or_json.is_a? String
26
- {id: page_id_or_json}
26
+ {"id" => page_id_or_json}
27
27
  else
28
28
  page_id_or_json
29
29
  end
@@ -38,7 +38,7 @@ module NotionRubyMapping
38
38
  page_ids_or_jsons = [page_ids_or_jsons] unless page_ids_or_jsons.is_a? Array
39
39
 
40
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
41
+ page_id_or_json.is_a?(String) ? {"id" => page_id_or_json} : page_id_or_json
42
42
  end
43
43
  end
44
44
 
@@ -48,20 +48,19 @@ module NotionRubyMapping
48
48
  # @see https://www.notion.so/hkob/RelationProperty-f608ab41a1f0476b98456620346fba03#eb40f1a2ad5c4e368d343870a7e529f9
49
49
  def relation_database_id
50
50
  assert_database_property __method__
51
- @json[:database_id]
51
+ @json["database_id"]
52
52
  end
53
53
 
54
54
  # @param [String] database_id
55
55
  # @param [String] synced_property_name
56
56
  # @see https://www.notion.so/hkob/RelationProperty-f608ab41a1f0476b98456620346fba03#7f5029fb7f6e4c009f22888b233e6f64
57
- def replace_relation_database(database_id: nil, type: :dual_property)
57
+ def replace_relation_database(database_id: nil, type: "dual_property")
58
58
  assert_database_property __method__
59
- type_sym = type.to_sym
60
59
  @will_update = true
61
- @json[:database_id] = database_id if database_id
62
- @json[:type] = type_sym.to_s
63
- @json[type_sym] = {}
64
- @json.delete type_sym == :dual_property ? :single_property : :dual_property
60
+ @json["database_id"] = database_id if database_id
61
+ @json["type"] = type
62
+ @json[type] = {}
63
+ @json.delete type == "dual_property" ? "single_property" : "dual_property"
65
64
  @json
66
65
  end
67
66
 
@@ -72,14 +71,14 @@ module NotionRubyMapping
72
71
  # @param [String, Symbol] name
73
72
  # @param [Hash, Array] json
74
73
  # @param [String, Array] relation
75
- def initialize(name, will_update: false, json: nil, relation: nil, base_type: :page, property_id: nil,
74
+ def initialize(name, will_update: false, json: nil, relation: nil, base_type: "page", property_id: nil,
76
75
  property_cache: nil, query: nil)
77
76
  super name, will_update: will_update, base_type: base_type, property_id: property_id,
78
77
  property_cache: property_cache, query: query
79
78
  @json = if database?
80
79
  json || {}
81
80
  elsif relation
82
- Array(relation).map { |r| {id: r} }
81
+ Array(relation).map { |r| {"id" => r} }
83
82
  else
84
83
  json || []
85
84
  end
@@ -94,20 +93,20 @@ module NotionRubyMapping
94
93
  return ans if ans != {} || !@will_update
95
94
 
96
95
  ans[@name] ||= {}
97
- ans[@name][:relation] = @json
96
+ ans[@name]["relation"] = @json
98
97
  ans
99
98
  end
100
99
 
101
100
  def database_id
102
- @json[:database_id]
101
+ @json["database_id"]
103
102
  end
104
103
 
105
104
  def synced_property_id
106
- @json[:type] == "dual_property" ? @json[:dual_property][:synced_property_id] : nil
105
+ @json["type"] == "dual_property" ? @json["dual_property"]["synced_property_id"] : nil
107
106
  end
108
107
 
109
108
  def synced_property_name
110
- @json[:type] == "dual_property" ? @json[:dual_property][:synced_property_name] : nil
109
+ @json["type"] == "dual_property" ? @json["dual_property"]["synced_property_name"] : nil
111
110
  end
112
111
 
113
112
  # @return [Hash] created json
@@ -115,8 +114,8 @@ module NotionRubyMapping
115
114
  assert_page_property __method__
116
115
  {
117
116
  @name => {
118
- type: "relation",
119
- relation: @json,
117
+ "type" => "relation",
118
+ "relation" => @json,
120
119
  },
121
120
  }
122
121
  end
@@ -3,7 +3,7 @@
3
3
  module NotionRubyMapping
4
4
  # RichTextProperty
5
5
  class RichTextProperty < TextProperty
6
- TYPE = :rich_text
6
+ TYPE = "rich_text"
7
7
 
8
8
  ### Not public announced methods
9
9
 
@@ -13,9 +13,9 @@ module NotionRubyMapping
13
13
  def update_from_json(json)
14
14
  @will_update = false
15
15
  if database?
16
- @json = json[:rich_text] || {}
16
+ @json = json["rich_text"] || {}
17
17
  else
18
- @text_objects = RichTextArray.new :rich_text, json: json[:rich_text]
18
+ @text_objects = RichTextArray.new "rich_text", json: json["rich_text"]
19
19
  end
20
20
  end
21
21
 
@@ -27,8 +27,8 @@ module NotionRubyMapping
27
27
  text_json = @text_objects.map(&:property_values_json)
28
28
  {
29
29
  @name => {
30
- type: "rich_text",
31
- rich_text: text_json.empty? ? (@json || []) : text_json,
30
+ "type" => "rich_text",
31
+ "rich_text" => text_json.empty? ? (@json || []) : text_json,
32
32
  },
33
33
  }
34
34
  end
@@ -6,7 +6,7 @@ module NotionRubyMapping
6
6
  include ContainsDoesNotContain
7
7
  include StartsWithEndsWith
8
8
  include GreaterThanLessThan
9
- TYPE = :rollup
9
+ TYPE = "rollup"
10
10
 
11
11
  ### Public announced methods
12
12
 
@@ -24,7 +24,7 @@ module NotionRubyMapping
24
24
  # @see https://www.notion.so/hkob/RollupProperty-eb10fbac3a93436289e74e5c651e9134#94021d4e6c0b44519443c1e1cc6b3aba
25
25
  def function
26
26
  assert_database_property __method__
27
- @json[:function]
27
+ @json["function"]
28
28
  end
29
29
 
30
30
  # @param [String] func
@@ -32,14 +32,14 @@ module NotionRubyMapping
32
32
  def function=(func)
33
33
  assert_database_property __method__
34
34
  @will_update = true
35
- @json[:function] = func
35
+ @json["function"] = func
36
36
  end
37
37
 
38
38
  # @return [String] new or settled relation_property_name
39
39
  # @see https://www.notion.so/hkob/RollupProperty-eb10fbac3a93436289e74e5c651e9134#684fc4739c4f4d6a9b93687f72cd8dad
40
40
  def relation_property_name
41
41
  assert_database_property __method__
42
- @json[:relation_property_name]
42
+ @json["relation_property_name"]
43
43
  end
44
44
 
45
45
  # @param [String] rpn
@@ -47,14 +47,14 @@ module NotionRubyMapping
47
47
  def relation_property_name=(rpn)
48
48
  assert_database_property __method__
49
49
  @will_update = true
50
- @json[:relation_property_name] = rpn
50
+ @json["relation_property_name"] = rpn
51
51
  end
52
52
 
53
53
  # @return [String] new or settled rollup_property_name
54
54
  # @see https://www.notion.so/hkob/RollupProperty-eb10fbac3a93436289e74e5c651e9134#8ce9ee31a2e2473ab7ba21781e4b440d
55
55
  def rollup_property_name
56
56
  assert_database_property __method__
57
- @json[:rollup_property_name]
57
+ @json["rollup_property_name"]
58
58
  end
59
59
 
60
60
  # @param [String] rpn
@@ -62,7 +62,7 @@ module NotionRubyMapping
62
62
  def rollup_property_name=(rpn)
63
63
  assert_database_property __method__
64
64
  @will_update = true
65
- @json[:rollup_property_name] = rpn
65
+ @json["rollup_property_name"] = rpn
66
66
  end
67
67
 
68
68
  ### Not public announced methods
@@ -71,7 +71,7 @@ module NotionRubyMapping
71
71
 
72
72
  # @param [String, Symbol] name
73
73
  # @param [Hash] json
74
- def initialize(name, will_update: false, json: nil, base_type: :page, property_id: nil,
74
+ def initialize(name, will_update: false, json: nil, base_type: "page", property_id: nil,
75
75
  property_cache: nil, query: nil)
76
76
  super name, will_update: will_update, base_type: base_type, property_id: property_id,
77
77
  property_cache: property_cache, query: query
@@ -87,10 +87,10 @@ module NotionRubyMapping
87
87
  return ans if ans != {} || !@will_update
88
88
 
89
89
  ans[@name] ||= {}
90
- ans[@name][:rollup] ||= {}
91
- ans[@name][:rollup][:function] = function
92
- ans[@name][:rollup][:relation_property_name] = relation_property_name
93
- ans[@name][:rollup][:rollup_property_name] = rollup_property_name
90
+ ans[@name]["rollup"] ||= {}
91
+ ans[@name]["rollup"]["function"] = function
92
+ ans[@name]["rollup"]["relation_property_name"] = relation_property_name
93
+ ans[@name]["rollup"]["rollup_property_name"] = rollup_property_name
94
94
  ans
95
95
  end
96
96
 
@@ -108,9 +108,9 @@ module NotionRubyMapping
108
108
  # @return [Hash]
109
109
  def property_schema_json_sub
110
110
  {
111
- function: function,
112
- relation_property_name: relation_property_name,
113
- rollup_property_name: rollup_property_name,
111
+ "function" => function,
112
+ "relation_property_name" => relation_property_name,
113
+ "rollup_property_name" => rollup_property_name,
114
114
  }
115
115
  end
116
116
  end
@@ -5,7 +5,7 @@ module NotionRubyMapping
5
5
  class SelectProperty < Property
6
6
  include EqualsDoesNotEqual
7
7
  include IsEmptyIsNotEmpty
8
- TYPE = :select
8
+ TYPE = "select"
9
9
 
10
10
  ### Public announced methods
11
11
 
@@ -23,7 +23,7 @@ module NotionRubyMapping
23
23
  # @see https://www.notion.so/hkob/SelectProperty-6d6a0defa70d4b26af0fdbdcfbf99f28#27a05e52715a4acd9156b5f146653e51
24
24
  def select_name
25
25
  assert_page_property __method__
26
- @json[:name]
26
+ @json["name"]
27
27
  end
28
28
 
29
29
  ## Database property only methods
@@ -33,28 +33,28 @@ module NotionRubyMapping
33
33
  # @return [Array] added array
34
34
  # @see https://www.notion.so/hkob/SelectProperty-6d6a0defa70d4b26af0fdbdcfbf99f28#3e1c7dbda7fb455f94ee93d9653b7880
35
35
  def add_select_option(name:, color:)
36
- edit_select_options << {name: name, color: color}
36
+ edit_select_options << {"name" => name, "color" => color}
37
37
  end
38
38
 
39
39
  # @return [Array] copyed multi select options
40
40
  def edit_select_options
41
41
  assert_database_property __method__
42
42
  @will_update = true
43
- @json[:options] ||= []
43
+ @json["options"] ||= []
44
44
  end
45
45
 
46
46
  # @return [Array]
47
47
  # @see https://www.notion.so/hkob/SelectProperty-6d6a0defa70d4b26af0fdbdcfbf99f28#790a297f2c1b4ba5a4d86074d4c70a89
48
48
  def select_options
49
49
  assert_database_property __method__
50
- @json[:options] || []
50
+ @json["options"] || []
51
51
  end
52
52
 
53
53
  # @return [String]
54
54
  # @see https://www.notion.so/hkob/SelectProperty-6d6a0defa70d4b26af0fdbdcfbf99f28#72da1632793c4a5296f3bc89de2df413
55
55
  def select_names
56
56
  assert_database_property __method__
57
- @json[:options].map { |s| s[:name] }
57
+ @json["options"].map { |s| s["name"] }
58
58
  end
59
59
 
60
60
  ## Page property only methods
@@ -64,7 +64,7 @@ module NotionRubyMapping
64
64
  def select=(select)
65
65
  assert_page_property __method__
66
66
  @will_update = true
67
- @json = {name: select}
67
+ @json = {"name" => select}
68
68
  end
69
69
 
70
70
  ### Not public announced methods
@@ -74,14 +74,14 @@ module NotionRubyMapping
74
74
  # @param [String, Symbol] 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, property_id: nil,
77
+ def initialize(name, will_update: false, base_type: "page", json: nil, select: nil, property_id: nil,
78
78
  property_cache: nil)
79
79
  super name, will_update: will_update, base_type: base_type, property_id: property_id,
80
80
  property_cache: property_cache
81
81
  @json = if database?
82
- json || {options: []}
82
+ json || {"options" => []}
83
83
  else
84
- json || {name: select}
84
+ json || {"name" => select}
85
85
  end
86
86
  end
87
87
 
@@ -94,8 +94,8 @@ module NotionRubyMapping
94
94
  return ans if ans != {} || !@will_update
95
95
 
96
96
  ans[@name] ||= {}
97
- ans[@name][:select] ||= {}
98
- ans[@name][:select][:options] = @json[:options]
97
+ ans[@name]["select"] ||= {}
98
+ ans[@name]["select"]["options"] = @json["options"]
99
99
  ans
100
100
  end
101
101
 
@@ -104,7 +104,7 @@ module NotionRubyMapping
104
104
  # @return [Hash]
105
105
  def property_values_json
106
106
  assert_page_property __method__
107
- {@name => {type: "select", select: @json}}
107
+ {@name => {"type" => "select", "select" => @json}}
108
108
  end
109
109
 
110
110
  protected
@@ -113,7 +113,7 @@ module NotionRubyMapping
113
113
 
114
114
  # @return [Hash]
115
115
  def property_schema_json_sub
116
- {options: edit_select_options}
116
+ {"options" => edit_select_options}
117
117
  end
118
118
  end
119
119
  end
@@ -5,7 +5,7 @@ module NotionRubyMapping
5
5
  class StatusProperty < Property
6
6
  include EqualsDoesNotEqual
7
7
  include IsEmptyIsNotEmpty
8
- TYPE = :status
8
+ TYPE = "status"
9
9
 
10
10
  ### Public announced methods
11
11
 
@@ -22,7 +22,7 @@ module NotionRubyMapping
22
22
  # @see https://www.notion.so/hkob/StatusProperty-c8b2c83019bc42edbc1527386c7ef453#69452ceee6c9452296e96bb2a37460ee
23
23
  def status_name
24
24
  assert_page_property __method__
25
- @json[:name]
25
+ @json["name"]
26
26
  end
27
27
 
28
28
  ## Page property only methods
@@ -32,7 +32,7 @@ module NotionRubyMapping
32
32
  def status=(status)
33
33
  assert_page_property __method__
34
34
  @will_update = true
35
- @json = {name: status}
35
+ @json = {"name" => status}
36
36
  end
37
37
 
38
38
  ### Not public announced methods
@@ -41,7 +41,7 @@ module NotionRubyMapping
41
41
 
42
42
  # @param [String, Symbol] name Property name
43
43
  # @param [Boolean, Hash] json
44
- def initialize(name, will_update: false, base_type: :page, property_id: nil, property_cache: nil, json: {})
44
+ def initialize(name, will_update: false, base_type: "page", property_id: nil, property_cache: nil, json: {})
45
45
  super name, will_update: will_update, base_type: base_type, property_id: property_id,
46
46
  property_cache: property_cache
47
47
  @json = json
@@ -52,7 +52,7 @@ module NotionRubyMapping
52
52
  # @return [Hash]
53
53
  def property_values_json
54
54
  assert_page_property __method__
55
- {@name => {status: @json, type: "status"}}
55
+ {@name => {"status" => @json, "type" => "status"}}
56
56
  end
57
57
  end
58
58
  end
@@ -27,7 +27,7 @@ module NotionRubyMapping
27
27
  # @param [String, Symbol] 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, property_id: nil,
30
+ def initialize(name, will_update: false, base_type: "page", json: nil, text_objects: nil, property_id: nil,
31
31
  property_cache: nil, query: nil)
32
32
  raise StandardError, "TextObject is abstract class. Please use RichTextProperty." if instance_of? TextProperty
33
33