notion_ruby_mapping 0.8.8 → 1.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 (93) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +12 -1
  3. data/README.md +1 -0
  4. data/lib/notion_ruby_mapping/blocks/base.rb +33 -33
  5. data/lib/notion_ruby_mapping/blocks/block.rb +48 -47
  6. data/lib/notion_ruby_mapping/blocks/bookmark_block.rb +1 -1
  7. data/lib/notion_ruby_mapping/blocks/breadcrumb_block.rb +1 -1
  8. data/lib/notion_ruby_mapping/blocks/bulleted_list_item_block.rb +1 -1
  9. data/lib/notion_ruby_mapping/blocks/callout_block.rb +10 -10
  10. data/lib/notion_ruby_mapping/blocks/child_base_block.rb +2 -2
  11. data/lib/notion_ruby_mapping/blocks/child_database_block.rb +3 -3
  12. data/lib/notion_ruby_mapping/blocks/child_page_block.rb +3 -3
  13. data/lib/notion_ruby_mapping/blocks/code_block.rb +7 -7
  14. data/lib/notion_ruby_mapping/blocks/column_block.rb +3 -3
  15. data/lib/notion_ruby_mapping/blocks/column_list_block.rb +2 -2
  16. data/lib/notion_ruby_mapping/blocks/database.rb +6 -6
  17. data/lib/notion_ruby_mapping/blocks/divider_block.rb +1 -1
  18. data/lib/notion_ruby_mapping/blocks/embed_block.rb +2 -2
  19. data/lib/notion_ruby_mapping/blocks/equation_block.rb +5 -5
  20. data/lib/notion_ruby_mapping/blocks/file_base_block.rb +2 -2
  21. data/lib/notion_ruby_mapping/blocks/file_block.rb +1 -1
  22. data/lib/notion_ruby_mapping/blocks/heading1_block.rb +4 -4
  23. data/lib/notion_ruby_mapping/blocks/heading2_block.rb +2 -2
  24. data/lib/notion_ruby_mapping/blocks/heading3_block.rb +3 -3
  25. data/lib/notion_ruby_mapping/blocks/image_block.rb +1 -1
  26. data/lib/notion_ruby_mapping/blocks/link_preview_block.rb +2 -2
  27. data/lib/notion_ruby_mapping/blocks/link_to_page_block.rb +5 -5
  28. data/lib/notion_ruby_mapping/blocks/list.rb +21 -20
  29. data/lib/notion_ruby_mapping/blocks/numbered_list_item_block.rb +2 -2
  30. data/lib/notion_ruby_mapping/blocks/page.rb +9 -10
  31. data/lib/notion_ruby_mapping/blocks/paragraph_block.rb +2 -2
  32. data/lib/notion_ruby_mapping/blocks/pdf_block.rb +2 -2
  33. data/lib/notion_ruby_mapping/blocks/quote_block.rb +1 -1
  34. data/lib/notion_ruby_mapping/blocks/synced_block.rb +5 -5
  35. data/lib/notion_ruby_mapping/blocks/table_block.rb +8 -8
  36. data/lib/notion_ruby_mapping/blocks/table_of_contents_block.rb +3 -3
  37. data/lib/notion_ruby_mapping/blocks/table_row_block.rb +3 -3
  38. data/lib/notion_ruby_mapping/blocks/template_block.rb +3 -3
  39. data/lib/notion_ruby_mapping/blocks/text_sub_block_color_base_block.rb +4 -4
  40. data/lib/notion_ruby_mapping/blocks/to_do_block.rb +4 -4
  41. data/lib/notion_ruby_mapping/blocks/toggle_block.rb +2 -2
  42. data/lib/notion_ruby_mapping/blocks/toggle_heading1_block.rb +2 -2
  43. data/lib/notion_ruby_mapping/blocks/toggle_heading2_block.rb +2 -2
  44. data/lib/notion_ruby_mapping/blocks/toggle_heading3_block.rb +3 -3
  45. data/lib/notion_ruby_mapping/blocks/url_base_block.rb +3 -3
  46. data/lib/notion_ruby_mapping/blocks/url_caption_base_block.rb +4 -4
  47. data/lib/notion_ruby_mapping/blocks/video_block.rb +2 -2
  48. data/lib/notion_ruby_mapping/controllers/discussion_thread.rb +1 -1
  49. data/lib/notion_ruby_mapping/controllers/mermaid_database.rb +34 -34
  50. data/lib/notion_ruby_mapping/controllers/notion_cache.rb +6 -8
  51. data/lib/notion_ruby_mapping/controllers/payload.rb +11 -11
  52. data/lib/notion_ruby_mapping/controllers/property_cache.rb +8 -7
  53. data/lib/notion_ruby_mapping/controllers/query.rb +10 -10
  54. data/lib/notion_ruby_mapping/controllers/search.rb +5 -6
  55. data/lib/notion_ruby_mapping/objects/comment_object.rb +2 -2
  56. data/lib/notion_ruby_mapping/objects/emoji_object.rb +3 -3
  57. data/lib/notion_ruby_mapping/objects/equation_object.rb +3 -3
  58. data/lib/notion_ruby_mapping/objects/file_object.rb +9 -9
  59. data/lib/notion_ruby_mapping/objects/mention_object.rb +43 -43
  60. data/lib/notion_ruby_mapping/objects/rich_text_object.rb +43 -43
  61. data/lib/notion_ruby_mapping/objects/text_object.rb +5 -5
  62. data/lib/notion_ruby_mapping/objects/user_object.rb +4 -4
  63. data/lib/notion_ruby_mapping/properties/button_property.rb +4 -4
  64. data/lib/notion_ruby_mapping/properties/checkbox_property.rb +3 -3
  65. data/lib/notion_ruby_mapping/properties/created_by_property.rb +3 -3
  66. data/lib/notion_ruby_mapping/properties/created_time_property.rb +2 -2
  67. data/lib/notion_ruby_mapping/properties/date_base_property.rb +14 -13
  68. data/lib/notion_ruby_mapping/properties/date_property.rb +17 -17
  69. data/lib/notion_ruby_mapping/properties/email_property.rb +3 -3
  70. data/lib/notion_ruby_mapping/properties/files_property.rb +16 -13
  71. data/lib/notion_ruby_mapping/properties/formula_property.rb +7 -7
  72. data/lib/notion_ruby_mapping/properties/last_edited_by_property.rb +2 -2
  73. data/lib/notion_ruby_mapping/properties/last_edited_time_property.rb +2 -2
  74. data/lib/notion_ruby_mapping/properties/multi_select_property.rb +15 -15
  75. data/lib/notion_ruby_mapping/properties/number_property.rb +9 -9
  76. data/lib/notion_ruby_mapping/properties/people_property.rb +6 -6
  77. data/lib/notion_ruby_mapping/properties/phone_number_property.rb +4 -4
  78. data/lib/notion_ruby_mapping/properties/property.rb +78 -74
  79. data/lib/notion_ruby_mapping/properties/relation_property.rb +18 -17
  80. data/lib/notion_ruby_mapping/properties/rich_text_property.rb +5 -5
  81. data/lib/notion_ruby_mapping/properties/rollup_property.rb +15 -15
  82. data/lib/notion_ruby_mapping/properties/select_property.rb +14 -14
  83. data/lib/notion_ruby_mapping/properties/status_property.rb +5 -5
  84. data/lib/notion_ruby_mapping/properties/text_property.rb +1 -1
  85. data/lib/notion_ruby_mapping/properties/title_property.rb +6 -6
  86. data/lib/notion_ruby_mapping/properties/unique_id_property.rb +3 -3
  87. data/lib/notion_ruby_mapping/properties/url_property.rb +3 -3
  88. data/lib/notion_ruby_mapping/properties/verification_property.rb +41 -0
  89. data/lib/notion_ruby_mapping/version.rb +1 -1
  90. data/lib/notion_ruby_mapping.rb +1 -1
  91. data/notion_ruby_mapping.gemspec +1 -2
  92. metadata +5 -22
  93. data/sig/notion_ruby_mapping.rbs +0 -4
@@ -3,16 +3,16 @@
3
3
  module NotionRubyMapping
4
4
  # Notion block
5
5
  class ToggleHeading3Block < TextSubBlockColorBaseBlock
6
- # @return [String (frozen)]
6
+ # @return [Symbol]
7
7
  def type
8
- "heading_3"
8
+ :heading_3
9
9
  end
10
10
 
11
11
  # @param [Boolean] not_update false when update
12
12
  # @return [Hash{String (frozen)->Hash}]
13
13
  def block_json(not_update: true)
14
14
  ans = super
15
- ans[type]["is_toggleable"] = true
15
+ ans[type][:is_toggleable] = true
16
16
  ans
17
17
  end
18
18
  end
@@ -9,7 +9,7 @@ module NotionRubyMapping
9
9
 
10
10
  super(json: json, id: id, parent: parent)
11
11
  @url = if @json
12
- @json[type]["url"]
12
+ @json[type][:url]
13
13
  else
14
14
  url
15
15
  end
@@ -21,14 +21,14 @@ module NotionRubyMapping
21
21
  # @return [Hash{String (frozen)->Hash}]
22
22
  def block_json(not_update: true)
23
23
  ans = super
24
- ans[type] = {"url" => @url}
24
+ ans[type] = {url: @url}
25
25
  ans
26
26
  end
27
27
 
28
28
  # @param [String] str
29
29
  def url=(str)
30
30
  @url = str
31
- @payload.add_update_block_key "url"
31
+ @payload.add_update_block_key :url
32
32
  end
33
33
  end
34
34
  end
@@ -12,11 +12,11 @@ module NotionRubyMapping
12
12
 
13
13
  super(json: json, id: id, parent: parent)
14
14
  if @json
15
- @url = @json[type]["url"]
15
+ @url = @json[type][:url]
16
16
  decode_block_caption
17
17
  else
18
18
  @url = url
19
- @caption = RichTextArray.rich_text_array "caption", caption
19
+ @caption = RichTextArray.rich_text_array :caption, caption
20
20
  end
21
21
  end
22
22
 
@@ -31,7 +31,7 @@ module NotionRubyMapping
31
31
  def block_json(not_update: true)
32
32
  ans = super
33
33
  ans[type] = @caption.update_property_schema_json not_update
34
- ans[type]["url"] = @url
34
+ ans[type][:url] = @url
35
35
  ans
36
36
  end
37
37
 
@@ -40,7 +40,7 @@ module NotionRubyMapping
40
40
  # @see https://www.notion.so/hkob/EmbedBlock-57c31e7d8e1d41669eb30f27e1c41035#25ece6bfce0749f8b4bbecc6ba7feedc
41
41
  def url=(str)
42
42
  @url = str
43
- @payload.add_update_block_key "url"
43
+ @payload.add_update_block_key :url
44
44
  end
45
45
  end
46
46
  end
@@ -3,9 +3,9 @@
3
3
  module NotionRubyMapping
4
4
  # Notion block
5
5
  class VideoBlock < FileBaseBlock
6
- # @return [String (frozen)]
6
+ # @return [Symbol]
7
7
  def type
8
- "video"
8
+ :video
9
9
  end
10
10
  end
11
11
  end
@@ -16,7 +16,7 @@ module NotionRubyMapping
16
16
  def append_comment(text_objects, dry_run: false)
17
17
  rto = RichTextArray.new "rich_text", text_objects: text_objects, will_update: true
18
18
  nc = NotionCache.instance
19
- json = rto.property_schema_json.merge({"discussion_id" => @discussion_id})
19
+ json = rto.property_schema_json.merge({discussion_id: @discussion_id})
20
20
  if dry_run
21
21
  Base.dry_run_script :post, nc.comments_path, json
22
22
  else
@@ -1,6 +1,5 @@
1
1
  module NotionRubyMapping
2
2
  class MermaidDatabase
3
-
4
3
  def initialize(key)
5
4
  @key = key
6
5
  @name = key
@@ -17,10 +16,11 @@ module NotionRubyMapping
17
16
  attr_accessor :name
18
17
 
19
18
  def add_property(key, value)
20
- if key == "title"
19
+ key_sym = key.to_sym
20
+ if key_sym == :title
21
21
  @title = value
22
22
  else
23
- @properties[value] = key
23
+ @properties[value] = key_sym
24
24
  end
25
25
  end
26
26
 
@@ -44,7 +44,7 @@ module NotionRubyMapping
44
44
  end
45
45
 
46
46
  def blocked?(name)
47
- @finish_flag[name].nil?
47
+ @finish_flag[name.to_sym].nil?
48
48
  end
49
49
 
50
50
  def count
@@ -66,10 +66,12 @@ module NotionRubyMapping
66
66
  ps = @real_db.properties
67
67
  @properties.each do |(value, key)|
68
68
  name, *options = value.split("|")
69
- next if @finish_flag[name]
69
+ name_sym = name.to_sym
70
+ key_sym = key.to_sym
71
+ next if @finish_flag[name_sym]
70
72
 
71
- property = ps.values_at(name).first
72
- case key
73
+ property = ps.values_at(name_sym).first
74
+ case key_sym
73
75
  when /checkbox|created_by|created_time|date|email|files|last_edited_by|last_edited_time|people|phone_number|text|url|status/
74
76
  klass = {
75
77
  checkbox: CheckboxProperty, created_by: CreatedByProperty, created_time: CreatedTimeProperty,
@@ -77,9 +79,9 @@ module NotionRubyMapping
77
79
  last_edited_time: LastEditedTimeProperty, people: PeopleProperty, phone_number: PhoneNumberProperty,
78
80
  rich_text: RichTextProperty, url: UrlProperty, status: StatusProperty
79
81
  }[key.to_sym]
80
- @real_db.add_property klass, name unless property
81
- @working << name
82
- when "formula"
82
+ @real_db.add_property klass, name_sym unless property
83
+ @working << name_sym
84
+ when :formula
83
85
  f_e = options.first&.gsub "@", '"'
84
86
  dependencies = f_e&.scan(/prop\("([^"]+)"\)/) || []
85
87
  blocked_key = dependencies.select { |k| blocked? k.first }
@@ -87,37 +89,37 @@ module NotionRubyMapping
87
89
  if property
88
90
  property.formula_expression = f_e unless property.formula_expression == f_e
89
91
  else
90
- @real_db.add_property(FormulaProperty, name) { |dp| dp.formula_expression = f_e }
92
+ @real_db.add_property(FormulaProperty, name_sym) { |dp| dp.formula_expression = f_e }
91
93
  end
92
- @working << name
94
+ @working << name_sym
93
95
  else
94
- print("#{name} blocked by #{blocked_key.flatten}\n")
96
+ print("#{name_sym} blocked by #{blocked_key.flatten}\n")
95
97
  next
96
98
  end
97
99
 
98
- when "multi_select"
100
+ when :multi_select
99
101
  if property
100
- (options - (property.multi_select_options.map { |h| h["name"] })).each do |select_name|
102
+ (options - (property.multi_select_options.map { |h| h[:name] })).each do |select_name|
101
103
  property.add_multi_select_option name: select_name, color: "default"
102
104
  end
103
105
  else
104
- @real_db.add_property(MultiSelectProperty, name) do |dp|
106
+ @real_db.add_property(MultiSelectProperty, name_sym) do |dp|
105
107
  options.each do |select_name|
106
108
  dp.add_multi_select_option name: select_name, color: "default"
107
109
  end
108
110
  end
109
111
  end
110
- @working << name
111
- when "number"
112
+ @working << name_sym
113
+ when :number
112
114
  format_value = options.empty? ? "number" : options.first
113
115
  if property
114
116
  property.format = format_value unless property.format == format_value
115
117
  else
116
- @real_db.add_property(NumberProperty, name) { |p| p.format = format_value }
118
+ @real_db.add_property(NumberProperty, name_sym) { |p| p.format = format_value }
117
119
  end
118
- @working << name
119
- when "rollup"
120
- name, *options = value.split("|")
120
+ @working << name_sym
121
+ when :rollup
122
+ name, *options = value.split("|").map(&:to_sym)
121
123
  relation_name, rollup_name, function = options
122
124
  if blocked? relation_name
123
125
  print("#{name} blocked by #{relation_name}\n")
@@ -144,9 +146,9 @@ module NotionRubyMapping
144
146
  @working << name
145
147
  end
146
148
  end
147
- when "select"
149
+ when :select
148
150
  if property
149
- (options - (property.select_options.map { |h| h["name"] })).each do |select_name|
151
+ (options - (property.select_options.map { |h| h[:name] })).each do |select_name|
150
152
  property.add_select_option name: select_name, color: "default"
151
153
  end
152
154
  else
@@ -157,19 +159,17 @@ module NotionRubyMapping
157
159
  end
158
160
  end
159
161
  @working << name
160
- else
161
- nil
162
162
  end
163
163
  end
164
- while (array = @relation_queue.shift) do
164
+ while (array = @relation_queue.shift)
165
165
  value, relation_db = array
166
166
  db_id = relation_db.real_db.id
167
- forward, reverse = value.split "|"
167
+ forward, reverse = value.split("|").map(&:to_sym)
168
168
  property = ps.values_at(forward).first
169
169
  if property
170
170
  if reverse
171
171
  if property.database_id == db_id && property.synced_property_name == reverse
172
- relation_db.add_property "relation", reverse
172
+ relation_db.add_property :relation, reverse
173
173
  relation_db.finish_flag[reverse] = true
174
174
  else
175
175
  unless @finish_flag[forward]
@@ -177,14 +177,14 @@ module NotionRubyMapping
177
177
  relation_db.append_reverse_name_queue self, forward, reverse
178
178
  end
179
179
  @working << forward
180
- add_property "relation", forward
180
+ add_property :relation, forward
181
181
  end
182
182
  relation_db.relations[reverse] = self
183
183
  else
184
184
  unless property.database_id == db_id
185
185
  property.replace_relation_database database_id: db_id, type: "single_property"
186
186
  @working << forward
187
- add_property "relation", forward
187
+ add_property :relation, forward
188
188
  end
189
189
  end
190
190
  @relations[forward] = relation_db
@@ -200,7 +200,7 @@ module NotionRubyMapping
200
200
  end
201
201
  @relations[forward] = relation_db
202
202
  @working << forward
203
- add_property "relation", forward
203
+ add_property :relation, forward
204
204
  end
205
205
  end
206
206
  @real_db.property_schema_json
@@ -208,7 +208,7 @@ module NotionRubyMapping
208
208
 
209
209
  def append_reverse_name_queue(other_db, forward, reverse)
210
210
  @reverse_name_queue[reverse] = [other_db, forward]
211
- add_property "relation", reverse
211
+ add_property :relation, reverse
212
212
  end
213
213
 
214
214
  def update_database
@@ -243,4 +243,4 @@ module NotionRubyMapping
243
243
  @reverse_name_queue = {}
244
244
  end
245
245
  end
246
- end
246
+ end
@@ -2,7 +2,6 @@
2
2
 
3
3
  require "singleton"
4
4
  require "faraday"
5
- require "faraday_middleware"
6
5
 
7
6
  module NotionRubyMapping
8
7
  # singleton class of caching Notion objects
@@ -14,10 +13,10 @@ module NotionRubyMapping
14
13
  # @see https://www.notion.so/hkob/NotionCache-65e1599864d6425686d495a5a4b3a623#dca210788f114cf59464090782c073bf
15
14
  def initialize
16
15
  @object_hash = {}
17
- @client = Faraday::Connection.new "https://api.notion.com" do |builder|
18
- builder.use FaradayMiddleware::EncodeJson
19
- builder.use FaradayMiddleware::ParseJson
20
- builder.adapter Faraday.default_adapter
16
+ @client = Faraday.new "https://api.notion.com" do |conn|
17
+ conn.request :json
18
+ conn.response :json, parser_options: {symbolize_names: true}
19
+ conn.headers["Notion-Version"] = NotionRubyMapping::NOTION_VERSION
21
20
  end
22
21
  @notion_token = nil
23
22
  @wait = 0.3333
@@ -248,7 +247,6 @@ module NotionRubyMapping
248
247
  sleep @wait
249
248
  response = @client.send(method) do |request|
250
249
  request.headers["Authorization"] = "Bearer #{@notion_token}"
251
- request.headers["Notion-Version"] = NotionRubyMapping::NOTION_VERSION
252
250
  case method
253
251
  when :get, :delete
254
252
  request.url path, options
@@ -266,13 +264,13 @@ module NotionRubyMapping
266
264
  end
267
265
 
268
266
  def search(query)
269
- request(:post, search_path, options = query)
267
+ request(:post, search_path, query)
270
268
  end
271
269
 
272
270
  def search_path
273
271
  "v1/search"
274
272
  end
275
-
273
+
276
274
  # @param [String] token
277
275
  def token=(token)
278
276
  @notion_token = token
@@ -8,7 +8,7 @@ module NotionRubyMapping
8
8
  @update_block_key = []
9
9
  end
10
10
 
11
- # @param [String] key
11
+ # @param [Symbol] key
12
12
  def add_update_block_key(key)
13
13
  @update_block_key << key
14
14
  end
@@ -20,19 +20,19 @@ module NotionRubyMapping
20
20
  end
21
21
 
22
22
  def description=(text_objects)
23
- rta = RichTextArray.rich_text_array "description", text_objects
24
- @json.merge!(rta.update_property_schema_json true)
23
+ rta = RichTextArray.rich_text_array :description, text_objects
24
+ @json.merge!(rta.update_property_schema_json(true))
25
25
  end
26
26
 
27
27
  # @param [Boolean] flag
28
28
  def is_inline=(flag)
29
- @json["is_inline"] = flag
29
+ @json[:is_inline] = flag
30
30
  end
31
31
 
32
32
  # @param [Hash] json
33
33
  def merge_property(json)
34
- @json["properties"] ||= {}
35
- @json["properties"].merge!(json)
34
+ @json[:properties] ||= {}
35
+ @json[:properties].merge!(json)
36
36
  end
37
37
 
38
38
  # @return [Hash] created json
@@ -52,21 +52,21 @@ module NotionRubyMapping
52
52
  # @return [NotionRubyMapping::Payload] updated Payload
53
53
  def set_icon(emoji: nil, url: nil)
54
54
  payload = if emoji
55
- {"type" => "emoji", "emoji" => emoji}
55
+ {type: "emoji", emoji: emoji}
56
56
  elsif url
57
- {"type" => "external", "external" => {"url" => url}}
57
+ {type: "external", external: {url: url}}
58
58
  else
59
59
  {}
60
60
  end
61
- @json["icon"] = payload
61
+ @json[:icon] = payload
62
62
  self
63
63
  end
64
64
 
65
65
  def update_block_json(type, json)
66
66
  sub_json = json[type]
67
67
  ans = {type => sub_json.slice(*@update_block_key)}
68
- ans[type]["caption"] = sub_json["caption"] if sub_json["caption"]
69
- ans[type]["rich_text"] = sub_json["rich_text"] if sub_json["rich_text"]
68
+ ans[type][:caption] = sub_json[:caption] if sub_json[:caption]
69
+ ans[type][:rich_text] = sub_json[:rich_text] if sub_json[:rich_text]
70
70
  ans
71
71
  end
72
72
 
@@ -17,7 +17,8 @@ module NotionRubyMapping
17
17
  # @return [Property] Property for key
18
18
  # @see https://www.notion.so/hkob/PropertyCache-2451fa64a814432db4809831cc77ba25#9709e2b2a7a0479f9951291a501f65c8
19
19
  def [](key)
20
- @properties[key] ||= Property.create_from_json key, @json[key], @base_type, self
20
+ key_sym = key.to_sym
21
+ @properties[key_sym] ||= Property.create_from_json key_sym, @json[key_sym], @base_type, self
21
22
  end
22
23
 
23
24
  # @param [Property] property added Property
@@ -56,8 +57,8 @@ module NotionRubyMapping
56
57
  def property_values_json
57
58
  @properties.each_with_object({}) do |(_, property), ans|
58
59
  if property.will_update
59
- ans["properties"] ||= {}
60
- ans["properties"].merge! property.property_values_json
60
+ ans[:properties] ||= {}
61
+ ans[:properties].merge! property.property_values_json
61
62
  end
62
63
  end
63
64
  end
@@ -66,8 +67,8 @@ module NotionRubyMapping
66
67
  def property_schema_json
67
68
  @properties.each_with_object({}) do |(_, property), ans|
68
69
  if property.will_update
69
- ans["properties"] ||= {}
70
- ans["properties"].merge! property.property_schema_json
70
+ ans[:properties] ||= {}
71
+ ans[:properties].merge! property.property_schema_json
71
72
  end
72
73
  end
73
74
  end
@@ -76,8 +77,8 @@ module NotionRubyMapping
76
77
  def update_property_schema_json
77
78
  @properties.each_with_object({}) do |(_, property), ans|
78
79
  if property.will_update
79
- ans["properties"] ||= {}
80
- ans["properties"].merge! property.update_property_schema_json
80
+ ans[:properties] ||= {}
81
+ ans[:properties].merge! property.update_property_schema_json
81
82
  end
82
83
  end
83
84
  end
@@ -16,10 +16,10 @@ module NotionRubyMapping
16
16
  # @param [Query] another_query other query
17
17
  # @return [NotionRubyMapping::Query] updated self (Query object)
18
18
  def and(another_query)
19
- if @filter.key? "and"
20
- @filter["and"] << another_query.filter
19
+ if @filter.key? :and
20
+ @filter[:and] << another_query.filter
21
21
  else
22
- @filter = {"and" => [@filter, another_query.filter]}
22
+ @filter = {and: [@filter, another_query.filter]}
23
23
  end
24
24
  self
25
25
  end
@@ -27,26 +27,26 @@ module NotionRubyMapping
27
27
  # @param [NotionRubyMapping::Property] property
28
28
  # @return [NotionRubyMapping::Query] updated self (Query object)
29
29
  def ascending(property)
30
- key = property.is_a?(LastEditedTimeProperty) || property.is_a?(CreatedTimeProperty) ? "timestamp" : "property"
31
- @sort << {key => property.name, "direction" => "ascending"}
30
+ key = property.is_a?(LastEditedTimeProperty) || property.is_a?(CreatedTimeProperty) ? :timestamp : :property
31
+ @sort << {key => property.name, direction: "ascending"}
32
32
  self
33
33
  end
34
34
 
35
35
  # @param [NotionRubyMapping::Property] property
36
36
  # @return [NotionRubyMapping::Query] updated self (Query object)
37
37
  def descending(property)
38
- key = property.is_a?(LastEditedTimeProperty) || property.is_a?(CreatedTimeProperty) ? "timestamp" : "property"
39
- @sort << {key => property.name, "direction" => "descending"}
38
+ key = property.is_a?(LastEditedTimeProperty) || property.is_a?(CreatedTimeProperty) ? :timestamp : :property
39
+ @sort << {key => property.name, direction: "descending"}
40
40
  self
41
41
  end
42
42
 
43
43
  # @param [Query] other_query other query
44
44
  # @return [NotionRubyMapping::Query] updated self (Query object)
45
45
  def or(other_query)
46
- if @filter.key? "or"
47
- @filter["or"] << other_query.filter
46
+ if @filter.key? :or
47
+ @filter[:or] << other_query.filter
48
48
  else
49
- @filter = {"or" => [@filter, other_query.filter]}
49
+ @filter = {or: [@filter, other_query.filter]}
50
50
  end
51
51
  self
52
52
  end
@@ -1,6 +1,5 @@
1
1
  module NotionRubyMapping
2
2
  class Search
3
-
4
3
  def initialize(ascending: false, database_only: false, page_only: false, query: nil)
5
4
  @ascending = ascending
6
5
  @database_only = database_only
@@ -19,11 +18,11 @@ module NotionRubyMapping
19
18
 
20
19
  def payload
21
20
  ans = {}
22
- ans["sort"] = {"direction" => "ascending", "timestamp" => "last_edited_time"} if @ascending
23
- ans["filter"] = {"value" => "database", "property" => "object" } if @database_only
24
- ans["filter"] = {"value" => "page", "property" => "object" } if @page_only
25
- ans["query"] = @query if @query
21
+ ans[:sort] = {direction: "ascending", timestamp: "last_edited_time"} if @ascending
22
+ ans[:filter] = {value: "database", property: "object"} if @database_only
23
+ ans[:filter] = {value: "page", property: "object"} if @page_only
24
+ ans[:query] = @query if @query
26
25
  ans
27
26
  end
28
27
  end
29
- end
28
+ end
@@ -10,7 +10,7 @@ module NotionRubyMapping
10
10
  @json = {}
11
11
  elsif json
12
12
  @json = json
13
- @text_objects = RichTextArray.new "rich_text", json: json["rich_text"]
13
+ @text_objects = RichTextArray.new "rich_text", json: json[:rich_text]
14
14
  else
15
15
  raise StandardError, "Either text_objects or json is required CommentObject"
16
16
  end
@@ -19,7 +19,7 @@ module NotionRubyMapping
19
19
  attr_reader :will_update, :text_objects, :json
20
20
 
21
21
  def discussion_id
22
- NotionCache.instance.hex_id @json["discussion_id"]
22
+ NotionCache.instance.hex_id @json[:discussion_id]
23
23
  end
24
24
 
25
25
  # @return [String] full_text
@@ -6,7 +6,7 @@ module NotionRubyMapping
6
6
  # @param [String] emoji
7
7
  # @return [TextObject]
8
8
  def initialize(emoji: nil, json: {})
9
- @emoji = emoji || json && json["emoji"]
9
+ @emoji = emoji || json && json[:emoji]
10
10
  @will_update = false
11
11
  end
12
12
  attr_reader :will_update, :emoji
@@ -32,8 +32,8 @@ module NotionRubyMapping
32
32
  # @return [Hash]
33
33
  def property_values_json
34
34
  {
35
- "type" => "emoji",
36
- "emoji" => @emoji,
35
+ type: "emoji",
36
+ emoji: @emoji,
37
37
  }
38
38
  end
39
39
  end
@@ -6,7 +6,7 @@ module NotionRubyMapping
6
6
  # @param [String] expression
7
7
  # @return [TextObject]
8
8
  def initialize(expression, options = {})
9
- super "equation", {"plain_text" => expression}.merge(options)
9
+ super :equation, {plain_text: expression}.merge(options)
10
10
  @expression = expression
11
11
  @will_update = false
12
12
  end
@@ -27,7 +27,7 @@ module NotionRubyMapping
27
27
  # @see https://www.notion.so/hkob/EquationObject-cd50126fce544ad5bb76463a4269859b#155800e2c69d4676a2d74572ed8f0de8
28
28
  def expression=(expression)
29
29
  @expression = expression
30
- @options["plain_text"] = expression
30
+ @options[:plain_text] = expression
31
31
  @will_update = true
32
32
  end
33
33
 
@@ -41,7 +41,7 @@ module NotionRubyMapping
41
41
  # @return [Hash{String (frozen)->String}]
42
42
  def partial_property_values_json
43
43
  {
44
- "expression" => @expression,
44
+ expression: @expression,
45
45
  }
46
46
  end
47
47
  end
@@ -7,12 +7,12 @@ module NotionRubyMapping
7
7
  # @return [TextObject]
8
8
  def initialize(url: nil, json: {})
9
9
  if url
10
- @type = "external"
10
+ @type = :external
11
11
  @url = url
12
12
  elsif json
13
- @type = json["type"]
14
- @url = json[@type]["url"]
15
- @expiry_time = json[@type]["expiry_time"]
13
+ @type = json[:type].to_sym
14
+ @url = json[@type][:url]
15
+ @expiry_time = json[@type][:expiry_time]
16
16
  else
17
17
  raise StandardError, "FileObject requires url: or json:"
18
18
  end
@@ -33,14 +33,14 @@ module NotionRubyMapping
33
33
 
34
34
  # @return [TrueClass, FalseClass] true if "type" is "external"
35
35
  def external?
36
- @type == "external"
36
+ @type == :external
37
37
  end
38
38
 
39
39
  # @param [String] url
40
40
  # @see https://www.notion.so/hkob/FileObject-6218c354e985423a90904f47a985be33#6b841f75d0234a1aac93fb54348abb96
41
41
  def url=(url)
42
42
  @url = url
43
- @type = "external"
43
+ @type = :external
44
44
  @expiry_time = nil
45
45
  @will_update = true
46
46
  end
@@ -48,12 +48,12 @@ module NotionRubyMapping
48
48
  # @return [Hash]
49
49
  def property_values_json
50
50
  ans = {
51
- "type" => @type,
51
+ type: @type.to_s,
52
52
  @type => {
53
- "url" => @url,
53
+ url: @url,
54
54
  },
55
55
  }
56
- ans[@type]["expiry_time"] = @expiry_time if @expiry_time
56
+ ans[@type][:expiry_time] = @expiry_time if @expiry_time
57
57
  ans
58
58
  end
59
59
  end