notion_ruby_mapping 0.3.3 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +44 -1237
  3. data/env.yml.sample +0 -13
  4. data/examples/change_title.md +1 -1
  5. data/examples/renumbering_pages.md +3 -3
  6. data/examples/set_icon_to_all_icon_unsettled_pages.md +4 -4
  7. data/lib/notion_ruby_mapping/{base.rb → blocks/base.rb} +163 -92
  8. data/lib/notion_ruby_mapping/blocks/block.rb +145 -0
  9. data/lib/notion_ruby_mapping/blocks/bookmark_block.rb +11 -0
  10. data/lib/notion_ruby_mapping/blocks/breadcrumb_block.rb +19 -0
  11. data/lib/notion_ruby_mapping/blocks/bulleted_list_item_block.rb +11 -0
  12. data/lib/notion_ruby_mapping/blocks/callout_block.rb +82 -0
  13. data/lib/notion_ruby_mapping/blocks/child_base_block.rb +21 -0
  14. data/lib/notion_ruby_mapping/blocks/child_database_block.rb +11 -0
  15. data/lib/notion_ruby_mapping/blocks/child_page_block.rb +11 -0
  16. data/lib/notion_ruby_mapping/blocks/code_block.rb +50 -0
  17. data/lib/notion_ruby_mapping/blocks/column_block.rb +29 -0
  18. data/lib/notion_ruby_mapping/blocks/column_list_block.rb +33 -0
  19. data/lib/notion_ruby_mapping/{database.rb → blocks/database.rb} +41 -8
  20. data/lib/notion_ruby_mapping/blocks/divider_block.rb +19 -0
  21. data/lib/notion_ruby_mapping/blocks/embed_block.rb +11 -0
  22. data/lib/notion_ruby_mapping/blocks/equation_block.rb +43 -0
  23. data/lib/notion_ruby_mapping/blocks/file_base_block.rb +50 -0
  24. data/lib/notion_ruby_mapping/blocks/file_block.rb +11 -0
  25. data/lib/notion_ruby_mapping/blocks/heading1_block.rb +18 -0
  26. data/lib/notion_ruby_mapping/blocks/heading2_block.rb +18 -0
  27. data/lib/notion_ruby_mapping/blocks/heading3_block.rb +18 -0
  28. data/lib/notion_ruby_mapping/blocks/image_block.rb +11 -0
  29. data/lib/notion_ruby_mapping/blocks/link_preview_block.rb +16 -0
  30. data/lib/notion_ruby_mapping/blocks/link_to_page_block.rb +40 -0
  31. data/lib/notion_ruby_mapping/{list.rb → blocks/list.rb} +37 -6
  32. data/lib/notion_ruby_mapping/blocks/numbered_list_item_block.rb +11 -0
  33. data/lib/notion_ruby_mapping/blocks/page.rb +77 -0
  34. data/lib/notion_ruby_mapping/blocks/paragraph_block.rb +11 -0
  35. data/lib/notion_ruby_mapping/{block.rb → blocks/pdf_block.rb} +4 -3
  36. data/lib/notion_ruby_mapping/blocks/quote_block.rb +11 -0
  37. data/lib/notion_ruby_mapping/blocks/synced_block.rb +44 -0
  38. data/lib/notion_ruby_mapping/blocks/table_block.rb +50 -0
  39. data/lib/notion_ruby_mapping/blocks/table_of_contents_block.rb +34 -0
  40. data/lib/notion_ruby_mapping/blocks/table_row_block.rb +34 -0
  41. data/lib/notion_ruby_mapping/blocks/template_block.rb +34 -0
  42. data/lib/notion_ruby_mapping/blocks/text_sub_block_color_base_block.rb +45 -0
  43. data/lib/notion_ruby_mapping/blocks/to_do_block.rb +42 -0
  44. data/lib/notion_ruby_mapping/blocks/toggle_block.rb +11 -0
  45. data/lib/notion_ruby_mapping/blocks/toggle_heading1_block.rb +11 -0
  46. data/lib/notion_ruby_mapping/blocks/toggle_heading2_block.rb +11 -0
  47. data/lib/notion_ruby_mapping/blocks/toggle_heading3_block.rb +11 -0
  48. data/lib/notion_ruby_mapping/blocks/url_base_block.rb +34 -0
  49. data/lib/notion_ruby_mapping/blocks/url_caption_base_block.rb +46 -0
  50. data/lib/notion_ruby_mapping/blocks/video_block.rb +11 -0
  51. data/lib/notion_ruby_mapping/{notion_cache.rb → controllers/notion_cache.rb} +144 -102
  52. data/lib/notion_ruby_mapping/{payload.rb → controllers/payload.rb} +32 -18
  53. data/lib/notion_ruby_mapping/{property_cache.rb → controllers/property_cache.rb} +21 -20
  54. data/lib/notion_ruby_mapping/{query.rb → controllers/query.rb} +27 -19
  55. data/lib/notion_ruby_mapping/{rich_text_array.rb → controllers/rich_text_array.rb} +39 -17
  56. data/lib/notion_ruby_mapping/objects/emoji_object.rb +40 -0
  57. data/lib/notion_ruby_mapping/objects/equation_object.rb +43 -0
  58. data/lib/notion_ruby_mapping/objects/file_object.rb +60 -0
  59. data/lib/notion_ruby_mapping/{mention_object.rb → objects/mention_object.rb} +11 -0
  60. data/lib/notion_ruby_mapping/{rich_text_object.rb → objects/rich_text_object.rb} +12 -4
  61. data/lib/notion_ruby_mapping/{text_object.rb → objects/text_object.rb} +0 -1
  62. data/lib/notion_ruby_mapping/{user_object.rb → objects/user_object.rb} +9 -4
  63. data/lib/notion_ruby_mapping/{checkbox_property.rb → properties/checkbox_property.rb} +3 -0
  64. data/lib/notion_ruby_mapping/{created_by_property.rb → properties/created_by_property.rb} +1 -0
  65. data/lib/notion_ruby_mapping/{created_time_property.rb → properties/created_time_property.rb} +1 -0
  66. data/lib/notion_ruby_mapping/properties/date_base_property.rb +135 -0
  67. data/lib/notion_ruby_mapping/{date_property.rb → properties/date_property.rb} +13 -0
  68. data/lib/notion_ruby_mapping/{email_property.rb → properties/email_property.rb} +2 -2
  69. data/lib/notion_ruby_mapping/{files_property.rb → properties/files_property.rb} +26 -13
  70. data/lib/notion_ruby_mapping/{formula_property.rb → properties/formula_property.rb} +5 -1
  71. data/lib/notion_ruby_mapping/{last_edited_by_property.rb → properties/last_edited_by_property.rb} +1 -0
  72. data/lib/notion_ruby_mapping/{last_edited_time_property.rb → properties/last_edited_time_property.rb} +1 -0
  73. data/lib/notion_ruby_mapping/{multi_property.rb → properties/multi_property.rb} +0 -0
  74. data/lib/notion_ruby_mapping/{multi_select_property.rb → properties/multi_select_property.rb} +4 -3
  75. data/lib/notion_ruby_mapping/{number_property.rb → properties/number_property.rb} +4 -0
  76. data/lib/notion_ruby_mapping/{people_property.rb → properties/people_property.rb} +8 -3
  77. data/lib/notion_ruby_mapping/{phone_number_property.rb → properties/phone_number_property.rb} +4 -1
  78. data/lib/notion_ruby_mapping/{property.rb → properties/property.rb} +33 -0
  79. data/lib/notion_ruby_mapping/{relation_property.rb → properties/relation_property.rb} +30 -10
  80. data/lib/notion_ruby_mapping/{rich_text_property.rb → properties/rich_text_property.rb} +0 -0
  81. data/lib/notion_ruby_mapping/{rollup_property.rb → properties/rollup_property.rb} +7 -0
  82. data/lib/notion_ruby_mapping/{select_property.rb → properties/select_property.rb} +8 -2
  83. data/lib/notion_ruby_mapping/{text_property.rb → properties/text_property.rb} +0 -0
  84. data/lib/notion_ruby_mapping/{title_property.rb → properties/title_property.rb} +0 -0
  85. data/lib/notion_ruby_mapping/{url_property.rb → properties/url_property.rb} +4 -1
  86. data/lib/notion_ruby_mapping/version.rb +1 -1
  87. data/lib/notion_ruby_mapping.rb +21 -7
  88. metadata +82 -40
  89. data/lib/notion_ruby_mapping/date_base_property.rb +0 -75
  90. data/lib/notion_ruby_mapping/page.rb +0 -50
@@ -1,50 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module NotionRubyMapping
4
- # Notion page object
5
- class Page < Base
6
- ### Public announced methods
7
-
8
- # @param [String] id
9
- # @return [NotionRubyMapping::Page, String]
10
- def self.find(id, dry_run: false)
11
- nc = NotionCache.instance
12
- if dry_run
13
- Base.dry_run_script :get, nc.page_path(id)
14
- else
15
- nc.page id
16
- end
17
- end
18
-
19
- def create_child_database(title, *assign)
20
- Database.new json: {"title" => [TextObject.new(title).property_values_json]},
21
- assign: assign, parent: {"type" => "page_id", "page_id" => @id}
22
- end
23
-
24
- protected
25
-
26
- # @return [NotionRubyMapping::Base, String]
27
- def create(dry_run: false)
28
- if dry_run
29
- dry_run_script :post, @nc.pages_path, :property_values_json
30
- else
31
- @new_record = false
32
- update_json @nc.create_page_request(property_values_json)
33
- end
34
- end
35
-
36
- # @return [Hash]
37
- def reload_json
38
- @nc.page_request @id
39
- end
40
-
41
- # @return [NotionRubyMapping::Base, String]
42
- def update(dry_run: false)
43
- if dry_run
44
- dry_run_script :patch, @nc.page_path(@id), :property_values_json
45
- else
46
- update_json @nc.update_page_request(@id, property_values_json)
47
- end
48
- end
49
- end
50
- end