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
@@ -59,7 +59,7 @@ module NotionRubyMapping
59
59
  .and(filter_before(end_date, another_type: another_type))
60
60
  end
61
61
  else
62
- make_filter_query :equals, value_str(date), condition: condition, another_type: another_type
62
+ make_filter_query "equals", value_str(date), condition: condition, another_type: another_type
63
63
  end
64
64
  end
65
65
 
@@ -77,7 +77,7 @@ module NotionRubyMapping
77
77
  .or(filter_after(end_date, another_type: another_type))
78
78
  end
79
79
  else
80
- make_filter_query :does_not_equal, value_str(date), condition: condition, another_type: another_type
80
+ make_filter_query "does_not_equal", value_str(date), condition: condition, another_type: another_type
81
81
  end
82
82
  end
83
83
 
@@ -86,7 +86,7 @@ module NotionRubyMapping
86
86
  # @return [NotionRubyMapping::Query] generated Query object
87
87
  # @see https://www.notion.so/hkob/CreatedTimeProperty-bb979ff02dc04efa9733da1003efa871#841815bfaf684964bebf3fa6712ae26c
88
88
  def filter_before(date, condition: nil, another_type: nil)
89
- make_filter_query :before, value_str(date, start_time: true), condition: condition, another_type: another_type
89
+ make_filter_query "before", value_str(date, start_time: true), condition: condition, another_type: another_type
90
90
  end
91
91
 
92
92
  # @param [String] condition Rollup name
@@ -94,7 +94,7 @@ module NotionRubyMapping
94
94
  # @return [NotionRubyMapping::Query] generated Query object
95
95
  # @see https://www.notion.so/hkob/CreatedTimeProperty-bb979ff02dc04efa9733da1003efa871#c0ea140866ea46f9a746b24773dc821c
96
96
  def filter_after(date, condition: nil, another_type: nil)
97
- make_filter_query :after, value_str(date, end_time: true), condition: condition, another_type: another_type
97
+ make_filter_query "after", value_str(date, end_time: true), condition: condition, another_type: another_type
98
98
  end
99
99
 
100
100
  # @param [String] condition Rollup name
@@ -102,7 +102,8 @@ module NotionRubyMapping
102
102
  # @return [NotionRubyMapping::Query] generated Query object
103
103
  # @see https://www.notion.so/hkob/CreatedTimeProperty-bb979ff02dc04efa9733da1003efa871#6a20ade0ee964aad81aae4c08ea29d6b
104
104
  def filter_on_or_before(date, condition: nil, another_type: nil)
105
- make_filter_query :on_or_before, value_str(date, end_time: true), condition: condition, another_type: another_type
105
+ make_filter_query "on_or_before", value_str(date, end_time: true), condition: condition,
106
+ another_type: another_type
106
107
  end
107
108
 
108
109
  # @param [String] condition Rollup name
@@ -110,8 +111,8 @@ module NotionRubyMapping
110
111
  # @return [NotionRubyMapping::Query] generated Query object
111
112
  # @see https://www.notion.so/hkob/CreatedTimeProperty-bb979ff02dc04efa9733da1003efa871#1469e3fb3068426a8ea8492d191d1563
112
113
  def filter_on_or_after(date, condition: nil, another_type: nil)
113
- make_filter_query :on_or_after, value_str(date, start_time: true), condition: condition,
114
- another_type: another_type
114
+ make_filter_query "on_or_after", value_str(date, start_time: true), condition: condition,
115
+ another_type: another_type
115
116
  end
116
117
 
117
118
  # @param [String] condition Rollup name
@@ -119,7 +120,7 @@ module NotionRubyMapping
119
120
  # @return [NotionRubyMapping::Query] generated Query object
120
121
  # @see https://www.notion.so/hkob/CreatedTimeProperty-bb979ff02dc04efa9733da1003efa871#707e7e848dc9417998420b65024542db
121
122
  def filter_past_week(condition: nil, another_type: nil)
122
- make_filter_query :past_week, {}, condition: condition, another_type: another_type
123
+ make_filter_query "past_week", {}, condition: condition, another_type: another_type
123
124
  end
124
125
 
125
126
  # @param [String] condition Rollup name
@@ -127,7 +128,7 @@ module NotionRubyMapping
127
128
  # @return [NotionRubyMapping::Query] generated Query object
128
129
  # @see https://www.notion.so/hkob/CreatedTimeProperty-bb979ff02dc04efa9733da1003efa871#7b2d05c549204c2eb68d95020d7b97c5
129
130
  def filter_past_month(condition: nil, another_type: nil)
130
- make_filter_query :past_month, {}, condition: condition, another_type: another_type
131
+ make_filter_query "past_month", {}, condition: condition, another_type: another_type
131
132
  end
132
133
 
133
134
  # @param [String] condition Rollup name
@@ -135,7 +136,7 @@ module NotionRubyMapping
135
136
  # @return [NotionRubyMapping::Query] generated Query object
136
137
  # @see https://www.notion.so/hkob/CreatedTimeProperty-bb979ff02dc04efa9733da1003efa871#9c8bf0a2398a41c8a0714a62afca3aa8
137
138
  def filter_past_year(condition: nil, another_type: nil)
138
- make_filter_query :past_year, {}, condition: condition, another_type: another_type
139
+ make_filter_query "past_year", {}, condition: condition, another_type: another_type
139
140
  end
140
141
 
141
142
  # @param [String] condition Rollup name
@@ -143,7 +144,7 @@ module NotionRubyMapping
143
144
  # @return [NotionRubyMapping::Query] generated Query object
144
145
  # @see
145
146
  def filter_this_week(condition: nil, another_type: nil)
146
- make_filter_query :this_week, {}, condition: condition, another_type: another_type
147
+ make_filter_query "this_week", {}, condition: condition, another_type: another_type
147
148
  end
148
149
 
149
150
  # @param [String] condition Rollup name
@@ -151,7 +152,7 @@ module NotionRubyMapping
151
152
  # @return [NotionRubyMapping::Query] generated Query object
152
153
  # @see https://www.notion.so/hkob/CreatedTimeProperty-bb979ff02dc04efa9733da1003efa871#d9dc189ee8244ba8a6c863259eaa9984
153
154
  def filter_next_week(condition: nil, another_type: nil)
154
- make_filter_query :next_week, {}, condition: condition, another_type: another_type
155
+ make_filter_query "next_week", {}, condition: condition, another_type: another_type
155
156
  end
156
157
 
157
158
  # @param [String] condition Rollup name
@@ -159,7 +160,7 @@ module NotionRubyMapping
159
160
  # @return [NotionRubyMapping::Query] generated Query object
160
161
  # @see https://www.notion.so/hkob/CreatedTimeProperty-bb979ff02dc04efa9733da1003efa871#0edb4dffbe6b403882255e870cc71066
161
162
  def filter_next_month(condition: nil, another_type: nil)
162
- make_filter_query :next_month, {}, condition: condition, another_type: another_type
163
+ make_filter_query "next_month", {}, condition: condition, another_type: another_type
163
164
  end
164
165
 
165
166
  # @param [String] condition Rollup name
@@ -167,7 +168,7 @@ module NotionRubyMapping
167
168
  # @return [NotionRubyMapping::Query] generated Query object
168
169
  # @see https://www.notion.so/hkob/CreatedTimeProperty-bb979ff02dc04efa9733da1003efa871#b59c73dd4b1a488f95d3e8cd19853709
169
170
  def filter_next_year(condition: nil, another_type: nil)
170
- make_filter_query :next_year, {}, condition: condition, another_type: another_type
171
+ make_filter_query "next_year", {}, condition: condition, another_type: another_type
171
172
  end
172
173
 
173
174
  # @param [Date, Time, DateTime, String, nil] obj
@@ -3,7 +3,7 @@
3
3
  module NotionRubyMapping
4
4
  # DateProperty
5
5
  class DateProperty < DateBaseProperty
6
- TYPE = :date
6
+ TYPE = "date"
7
7
 
8
8
  ### Public announced methods
9
9
 
@@ -21,12 +21,12 @@ module NotionRubyMapping
21
21
  # @see https://www.notion.so/hkob/DateProperty-c6e815c060cb430889dbb33b697f00c6#15f2088e012549cbae93de14ce14d352
22
22
  def end_date
23
23
  assert_page_property __method__
24
- @json[:end]
24
+ @json["end"]
25
25
  end
26
26
 
27
27
  def end_date_obj
28
28
  assert_page_property __method__
29
- jet = @json[:end]
29
+ jet = @json["end"]
30
30
  case jet
31
31
  when String
32
32
  jet.include?("T") ? Time.parse(jet) : Date.parse(jet)
@@ -42,19 +42,19 @@ module NotionRubyMapping
42
42
  @will_update = true
43
43
  # sdt = start_date
44
44
  # edt = nil if sdt.class != edt.class || sdt > edt
45
- @json[:end] = edt
45
+ @json["end"] = edt
46
46
  end
47
47
 
48
48
  # @return [Date, Time, DateTime, String]
49
49
  # @see https://www.notion.so/hkob/DateProperty-c6e815c060cb430889dbb33b697f00c6#d37097c7a3f7481e9b33a7aaae783888
50
50
  def start_date
51
51
  assert_page_property __method__
52
- @json[:start]
52
+ @json["start"]
53
53
  end
54
54
 
55
55
  def start_date_obj
56
56
  assert_page_property __method__
57
- jst = @json[:start]
57
+ jst = @json["start"]
58
58
  case jst
59
59
  when String
60
60
  jst.include?("T") ? Time.parse(jst) : Date.parse(jst)
@@ -70,7 +70,7 @@ module NotionRubyMapping
70
70
  @will_update = true
71
71
  # edt = end_date
72
72
  # @json["end"] = nil if sdt.class != edt.class || sdt > edt
73
- @json[:start] = sdt
73
+ @json["start"] = sdt
74
74
  end
75
75
 
76
76
  # @return [String]
@@ -97,7 +97,7 @@ module NotionRubyMapping
97
97
  # @param [Date, Time, DateTime, String, nil] start_date
98
98
  # @param [Date, Time, DateTime, String, nil] end_date
99
99
  # @param [String, nil] time_zone
100
- def initialize(name, will_update: false, base_type: :page, json: nil, start_date: nil, end_date: nil,
100
+ def initialize(name, will_update: false, base_type: "page", json: nil, start_date: nil, end_date: nil,
101
101
  time_zone: nil, property_id: nil, property_cache: nil)
102
102
  super name, will_update: will_update, base_type: base_type, property_id: property_id,
103
103
  property_cache: property_cache
@@ -105,9 +105,9 @@ module NotionRubyMapping
105
105
  return if database?
106
106
 
107
107
  @json = json || {}
108
- @json[:start] = start_date if start_date
109
- @json[:end] = end_date if end_date
110
- @json[:time_zone] = time_zone if time_zone
108
+ @json["start"] = start_date if start_date
109
+ @json["end"] = end_date if end_date
110
+ @json["time_zone"] = time_zone if time_zone
111
111
  end
112
112
 
113
113
  ## Page property only methods
@@ -117,11 +117,11 @@ module NotionRubyMapping
117
117
  assert_page_property __method__
118
118
  {
119
119
  @name => {
120
- type: TYPE.to_s,
121
- date: {
122
- start: value_str(@json[:start]),
123
- end: value_str(@json[:end]),
124
- time_zone: @json[:time_zone],
120
+ "type" => TYPE,
121
+ "date" => {
122
+ "start" => value_str(@json["start"]),
123
+ "end" => value_str(@json["end"]),
124
+ "time_zone" => @json["time_zone"],
125
125
  },
126
126
  },
127
127
  }
@@ -7,7 +7,7 @@ module NotionRubyMapping
7
7
  include ContainsDoesNotContain
8
8
  include StartsWithEndsWith
9
9
  include IsEmptyIsNotEmpty
10
- TYPE = :email
10
+ TYPE = "email"
11
11
 
12
12
  ### Public announced methods
13
13
 
@@ -32,7 +32,7 @@ module NotionRubyMapping
32
32
  ## Common methods
33
33
 
34
34
  # @param [String, Symbol] name Property name
35
- def initialize(name, will_update: false, base_type: :page, json: nil, property_id: nil, property_cache: nil)
35
+ def initialize(name, will_update: false, base_type: "page", json: nil, property_id: nil, property_cache: nil)
36
36
  super name, will_update: will_update, base_type: base_type, property_id: property_id,
37
37
  property_cache: property_cache
38
38
  @json = json || {}
@@ -41,7 +41,7 @@ module NotionRubyMapping
41
41
  # @return [Hash]
42
42
  def property_values_json
43
43
  assert_page_property __method__
44
- {@name => {email: @json, type: "email"}}
44
+ {@name => {"email" => @json, "type" => "email"}}
45
45
  end
46
46
  end
47
47
  end
@@ -4,7 +4,7 @@ module NotionRubyMapping
4
4
  # Select property
5
5
  class FilesProperty < Property
6
6
  include IsEmptyIsNotEmpty
7
- TYPE = :files
7
+ TYPE = "files"
8
8
 
9
9
  attr_reader :files
10
10
 
@@ -36,7 +36,7 @@ module NotionRubyMapping
36
36
 
37
37
  # @param [String, Symbol] name Property name
38
38
  # @param [String] files files value (optional)
39
- def initialize(name, will_update: false, base_type: :page, json: nil, files: [], property_id: nil,
39
+ def initialize(name, will_update: false, base_type: "page", json: nil, files: [], property_id: nil,
40
40
  property_cache: nil)
41
41
  super name, will_update: will_update, base_type: base_type, property_id: property_id,
42
42
  property_cache: property_cache
@@ -44,7 +44,7 @@ module NotionRubyMapping
44
44
  @files = json || {}
45
45
  elsif json
46
46
  @files = json.map { |sub_json| FileObject.new json: sub_json }
47
- @file_names = json.map { |sub_json| sub_json[:name] }
47
+ @file_names = json.map { |sub_json| sub_json["name"] }
48
48
  elsif !files.empty?
49
49
  @files = Array(files).map { |url| FileObject.file_object url }
50
50
  @file_names = Array(files)
@@ -56,20 +56,22 @@ module NotionRubyMapping
56
56
  # @return [Hash]
57
57
  def property_values_json
58
58
  assert_page_property __method__
59
- if @files.map(&:type).include? :file
59
+ if @files.map(&:type).include? "file"
60
60
  {}
61
61
  else
62
62
  files = @files.map(&:property_values_json)
63
- @file_names&.each_with_index { |name, i| files[i][:name] = name }
64
- {@name => {files: files, type: "files"}}
63
+ @file_names&.each_with_index do |name, i|
64
+ files[i]["name"] = name.is_a?(FileUploadObject) ? name.fname : name
65
+ end
66
+ {@name => {"files" => files, "type" => "files"}}
65
67
  end
66
68
  end
67
69
 
68
70
  def update_from_json(json)
69
71
  return if database?
70
72
 
71
- @files = json[:files].map { |sub_json| FileObject.new json: sub_json }
72
- @file_names = json[:files].map { |sub_json| sub_json[:name] }
73
+ @files = json["files"].map { |sub_json| FileObject.new json: sub_json }
74
+ @file_names = json["files"].map { |sub_json| sub_json["name"] }
73
75
  @will_update = false
74
76
  self
75
77
  end
@@ -80,10 +82,10 @@ module NotionRubyMapping
80
82
  # @return [Hash]
81
83
  def url_to_hash(url)
82
84
  {
83
- name: url,
84
- type: "external",
85
- external: {
86
- url: url,
85
+ "name" => url,
86
+ "type" => "external",
87
+ "external" => {
88
+ "url" => url,
87
89
  },
88
90
  }
89
91
  end
@@ -6,7 +6,7 @@ module NotionRubyMapping
6
6
  include ContainsDoesNotContain
7
7
  include StartsWithEndsWith
8
8
  include GreaterThanLessThan
9
- TYPE = :formula
9
+ TYPE = "formula"
10
10
 
11
11
  ### Public announced methods
12
12
 
@@ -24,7 +24,7 @@ module NotionRubyMapping
24
24
  # @see https://www.notion.so/hkob/FormulaProperty-d6b22ca70822407a9fef0bac8925cd0d#a24d2a7b99254d2a9226c00153f1d516
25
25
  def formula_expression
26
26
  assert_database_property __method__
27
- @json[:expression]
27
+ @json["expression"]
28
28
  end
29
29
 
30
30
  # @param [String] f_e
@@ -32,7 +32,7 @@ module NotionRubyMapping
32
32
  def formula_expression=(f_e)
33
33
  assert_database_property __method__
34
34
  @will_update = true
35
- @json[:expression] = f_e
35
+ @json["expression"] = f_e
36
36
  end
37
37
 
38
38
  ### Not public announced methods
@@ -41,14 +41,14 @@ module NotionRubyMapping
41
41
 
42
42
  # @param [String, Symbol] name
43
43
  # @param [Hash] json
44
- def initialize(name, will_update: false, base_type: :page, json: nil, formula: nil, property_id: nil,
44
+ def initialize(name, will_update: false, base_type: "page", json: nil, formula: nil, property_id: nil,
45
45
  property_cache: nil)
46
46
  super name, will_update: will_update, base_type: base_type, property_id: property_id,
47
47
  property_cache: property_cache
48
48
  @json = json || {}
49
49
  return unless database?
50
50
 
51
- @json[:expression] = formula if formula
51
+ @json["expression"] = formula if formula
52
52
  end
53
53
 
54
54
  ## Database property only methods
@@ -60,7 +60,7 @@ module NotionRubyMapping
60
60
  return ans if ans != {} || !@will_update
61
61
 
62
62
  ans[@name] ||= {}
63
- ans[@name][:formula] = @json
63
+ ans[@name]["formula"] = @json
64
64
  ans
65
65
  end
66
66
 
@@ -77,7 +77,7 @@ module NotionRubyMapping
77
77
 
78
78
  # @return [Hash]
79
79
  def property_schema_json_sub
80
- {expression: formula_expression}
80
+ {"expression" => formula_expression}
81
81
  end
82
82
  end
83
83
  end
@@ -3,7 +3,7 @@
3
3
  module NotionRubyMapping
4
4
  # LastEditedByProperty
5
5
  class LastEditedByProperty < MultiProperty
6
- TYPE = :last_edited_by
6
+ TYPE = "last_edited_by"
7
7
 
8
8
  ### Public announced methods
9
9
 
@@ -22,7 +22,8 @@ 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, property_id: nil,
25
+ def initialize(name, will_update: false, base_type:
26
+ "page", json: nil, user_id: nil, property_id: nil,
26
27
  property_cache: nil)
27
28
  super name, will_update: will_update, base_type: base_type, property_id: property_id,
28
29
  property_cache: property_cache
@@ -37,7 +38,7 @@ module NotionRubyMapping
37
38
  # @param [Hash] json
38
39
  def update_from_json(json)
39
40
  @will_update = false
40
- leb = json[:last_edited_by]
41
+ leb = json["last_edited_by"]
41
42
  @json = database? ? leb : UserObject.new(json: leb)
42
43
  end
43
44
 
@@ -3,7 +3,7 @@
3
3
  module NotionRubyMapping
4
4
  # LastEditedTimeProperty
5
5
  class LastEditedTimeProperty < DateBaseProperty
6
- TYPE = :last_edited_time
6
+ TYPE = "last_edited_time"
7
7
 
8
8
  ### Public announced methods
9
9
 
@@ -21,7 +21,7 @@ module NotionRubyMapping
21
21
 
22
22
  # @param [String, Symbol] 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_id: nil, property_cache: nil)
24
+ def initialize(name, will_update: false, base_type: "page", json: nil, property_id: nil, property_cache: nil)
25
25
  super name, will_update: will_update, base_type: base_type, property_id: property_id,
26
26
  property_cache: property_cache
27
27
  @json = json
@@ -3,7 +3,7 @@
3
3
  module NotionRubyMapping
4
4
  # MultiSelect property
5
5
  class MultiSelectProperty < MultiProperty
6
- TYPE = :multi_select
6
+ TYPE = "multi_select"
7
7
 
8
8
  ### Public announced methods
9
9
 
@@ -16,8 +16,8 @@ module NotionRubyMapping
16
16
 
17
17
  # @return [Array]
18
18
  def multi_select_names
19
- mshs = @base_type == :page ? @json : @json[:options]
20
- mshs.map { |h| h[:name] }
19
+ mshs = @base_type == "page" ? @json : @json["options"]
20
+ mshs.map { |h| h["name"] }
21
21
  end
22
22
 
23
23
  ## Database property only methods
@@ -27,21 +27,21 @@ module NotionRubyMapping
27
27
  # @return [Array] added array
28
28
  # @see https://www.notion.so/hkob/MultiSelectProperty-b90bba1c55d540ba97131bb013d4ca74#bcac830b00e04cb6bf7dbbb110d95667
29
29
  def add_multi_select_option(name:, color:)
30
- edit_multi_select_options << {name: name, color: color}
30
+ edit_multi_select_options << {"name" => name, "color" => color}
31
31
  end
32
32
 
33
33
  # @return [Array] copyed multi select options
34
34
  def edit_multi_select_options
35
35
  assert_database_property __method__
36
36
  @will_update = true
37
- @json[:options] ||= []
37
+ @json["options"] ||= []
38
38
  end
39
39
 
40
40
  # @return [Array]
41
41
  # @see https://www.notion.so/hkob/MultiSelectProperty-b90bba1c55d540ba97131bb013d4ca74#5ff6ec299cf64049bde2416f61b30fa9
42
42
  def multi_select_options
43
43
  assert_database_property __method__
44
- @json[:options] || []
44
+ @json["options"] || []
45
45
  end
46
46
 
47
47
  ## Page property only methods
@@ -51,7 +51,7 @@ module NotionRubyMapping
51
51
  def multi_select=(multi_select)
52
52
  assert_page_property __method__
53
53
  @will_update = true
54
- @json = multi_select ? Array(multi_select).map { |ms| {name: ms} } : []
54
+ @json = multi_select ? Array(multi_select).map { |ms| {"name" => ms} } : []
55
55
  end
56
56
 
57
57
  ### Not public announced methods
@@ -61,15 +61,15 @@ module NotionRubyMapping
61
61
  # @param [String, Symbol] 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,
64
+ def initialize(name, will_update: false, base_type: "page", json: nil, multi_select: nil,
65
65
  property_id: nil, property_cache: nil)
66
66
  super name, will_update: will_update, base_type: base_type, property_id: property_id,
67
67
  property_cache: property_cache
68
68
  if database?
69
- @json = json || {options: []}
69
+ @json = json || {"options" => []}
70
70
  else
71
71
  @json = json || []
72
- @json = Array(multi_select).map { |ms| {name: ms} } unless multi_select.nil?
72
+ @json = Array(multi_select).map { |ms| {"name" => ms} } unless multi_select.nil?
73
73
  end
74
74
  end
75
75
 
@@ -82,8 +82,8 @@ module NotionRubyMapping
82
82
  return ans if ans != {} || !@will_update
83
83
 
84
84
  ans[@name] ||= {}
85
- ans[@name][:multi_select] ||= {}
86
- ans[@name][:multi_select][:options] = @json[:options]
85
+ ans[@name]["multi_select"] ||= {}
86
+ ans[@name]["multi_select"]["options"] = @json["options"]
87
87
  ans
88
88
  end
89
89
 
@@ -94,8 +94,8 @@ module NotionRubyMapping
94
94
  assert_page_property __method__
95
95
  {
96
96
  @name => {
97
- type: "multi_select",
98
- multi_select: @json,
97
+ "type" => "multi_select",
98
+ "multi_select" => @json,
99
99
  },
100
100
  }
101
101
  end
@@ -106,7 +106,7 @@ module NotionRubyMapping
106
106
 
107
107
  # @return [Hash]
108
108
  def property_schema_json_sub
109
- {options: edit_multi_select_options}
109
+ {"options" => edit_multi_select_options}
110
110
  end
111
111
  end
112
112
  end
@@ -6,7 +6,7 @@ module NotionRubyMapping
6
6
  include EqualsDoesNotEqual
7
7
  include GreaterThanLessThan
8
8
  include IsEmptyIsNotEmpty
9
- TYPE = :number
9
+ TYPE = "number"
10
10
 
11
11
  ### Public announced methods
12
12
 
@@ -24,7 +24,7 @@ module NotionRubyMapping
24
24
  # @see https://www.notion.so/hkob/NumberProperty-964ebc1948074d7ca8340187aa352d40#5e3682ed9e124d518f735b236787d7a7
25
25
  def format
26
26
  assert_database_property __method__
27
- @json[:format]
27
+ @json["format"]
28
28
  end
29
29
 
30
30
  # @param [String] format
@@ -33,7 +33,7 @@ module NotionRubyMapping
33
33
  def format=(format)
34
34
  assert_database_property __method__
35
35
  @will_update = true
36
- @json[:format] = format
36
+ @json["format"] = format
37
37
  end
38
38
 
39
39
  ## Page property only methods
@@ -53,19 +53,19 @@ module NotionRubyMapping
53
53
 
54
54
  # @param [String, Symbol] 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, property_id: nil,
56
+ def initialize(name, will_update: false, base_type: "page", json: nil, format: nil, property_id: nil,
57
57
  property_cache: nil)
58
58
  super name, will_update: will_update, base_type: base_type, property_id: property_id,
59
59
  property_cache: property_cache
60
60
  @json = json
61
- @json ||= {format: format || "number"} if database?
61
+ @json ||= {"format" => format || "number"} if database?
62
62
  end
63
63
 
64
64
  # @param [Hash] json
65
65
  # @return [NotionRubyMapping::NumberProperty]
66
66
  def update_from_json(json)
67
67
  @will_update = false
68
- @json = json[:number]
68
+ @json = json["number"]
69
69
  self
70
70
  end
71
71
 
@@ -78,7 +78,7 @@ module NotionRubyMapping
78
78
  return ans if ans != {} || !@will_update
79
79
 
80
80
  ans[@name] ||= {}
81
- ans[@name][:number] = @json
81
+ ans[@name]["number"] = @json
82
82
  ans
83
83
  end
84
84
 
@@ -87,7 +87,7 @@ module NotionRubyMapping
87
87
  # @return [Hash]
88
88
  def property_values_json
89
89
  assert_page_property __method__
90
- {@name => {number: @json, type: "number"}}
90
+ {@name => {"number" => @json, "type" => "number"}}
91
91
  end
92
92
 
93
93
  protected
@@ -96,7 +96,7 @@ module NotionRubyMapping
96
96
 
97
97
  # @return [Hash]
98
98
  def property_schema_json_sub
99
- {format: format}
99
+ {"format" => format}
100
100
  end
101
101
  end
102
102
  end
@@ -3,7 +3,7 @@
3
3
  module NotionRubyMapping
4
4
  # PeopleProperty class
5
5
  class PeopleProperty < MultiProperty
6
- TYPE = :people
6
+ TYPE = "people"
7
7
 
8
8
  ### Public announced methods
9
9
 
@@ -42,17 +42,17 @@ module NotionRubyMapping
42
42
  def self.people_from_json(json)
43
43
  if json.is_a? Array
44
44
  json.map { |sub_json| UserObject.new json: sub_json }
45
- elsif json[:object] == "list"
46
- List.new(json: json, type: :property, value: self).select { true }
45
+ elsif json["object"] == "list"
46
+ List.new(json: json, type: "property", value: self).select { true }
47
47
  else
48
- json[:people].map { |sub_json| UserObject.new json: sub_json }
48
+ json["people"].map { |sub_json| UserObject.new json: sub_json }
49
49
  end
50
50
  end
51
51
 
52
52
  # @param [String, Symbol] name
53
53
  # @param [Hash] json
54
54
  # @param [Array] people ids for people
55
- def initialize(name, will_update: false, base_type: :page, json: nil, people: nil, property_id: nil,
55
+ def initialize(name, will_update: false, base_type: "page", json: nil, people: nil, property_id: nil,
56
56
  property_cache: nil, query: nil)
57
57
  super name, will_update: will_update, base_type: base_type, property_id: property_id,
58
58
  property_cache: property_cache, query: query
@@ -74,8 +74,8 @@ module NotionRubyMapping
74
74
  assert_page_property __method__
75
75
  {
76
76
  @name => {
77
- type: "people",
78
- people: @json.map(&:property_values_json),
77
+ "type" => "people",
78
+ "people" => @json.map(&:property_values_json),
79
79
  },
80
80
  }
81
81
  end
@@ -7,7 +7,7 @@ module NotionRubyMapping
7
7
  include ContainsDoesNotContain
8
8
  include StartsWithEndsWith
9
9
  include IsEmptyIsNotEmpty
10
- TYPE = :phone_number
10
+ TYPE = "phone_number"
11
11
 
12
12
  ### Public announced methods
13
13
 
@@ -34,7 +34,7 @@ module NotionRubyMapping
34
34
  ## Common methods
35
35
 
36
36
  # @param [String, Symbol] name Property name
37
- def initialize(name, will_update: false, base_type: :page, json: nil, property_id: nil, property_cache: nil)
37
+ def initialize(name, will_update: false, base_type: "page", json: nil, property_id: nil, property_cache: nil)
38
38
  super name, will_update: will_update, base_type: base_type, property_id: property_id,
39
39
  property_cache: property_cache
40
40
  @json = database? ? {} : json
@@ -44,7 +44,7 @@ module NotionRubyMapping
44
44
  # @return [Hash]
45
45
  def property_values_json
46
46
  assert_page_property __method__
47
- {@name => {phone_number: @json, type: "phone_number"}}
47
+ {@name => {"phone_number" => @json, "type" => "phone_number"}}
48
48
  end
49
49
  end
50
50
  end