notion_ruby_mapping 3.0.0 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2939f0091b98158d3e7f65b47ecc9b8a1e5d87c9e0546ac0b44ae76c03b3c97a
4
- data.tar.gz: 20ef7923ab54c9528a672c059ebac70d40c2f377156ec1f1789737bcd517bf13
3
+ metadata.gz: 0bd25791d37f43bba61d634c605af7bb8e5afd178d3166135d40231f96820912
4
+ data.tar.gz: 7aae9ec026d6acce1ad3ea4b542a5cd7db67caa2158c74835526f5699bc0cd90
5
5
  SHA512:
6
- metadata.gz: 49bce2621fb722fa1a3b38210b97931fec3eae6b2535a162bc658b4922a96225497eb4748f01693ecb204129332ca35ef965a7c64abfe45ee64f0cd058b08833
7
- data.tar.gz: af85f46e2068ac9f6569d5c4ba53e803a8bec5f08a28f7555b68ebb32e42c1e2b3313416c7451b6a86851c6be5411a5c3fd6441efcac9ee73ce80cfe4164538c
6
+ metadata.gz: 5b3db4c23fb05797ecbfea12b6bad3fdc7b5701c3abeaff964dd4fb86e1b91742d1986ba387e56c6ef2978d40a1a6f4df6017a059bdf993a424a246336d11e17
7
+ data.tar.gz: c76f986868915a57e973d109738e1ae7abbfcb8f861f956f68c9ea2914d3f88a95f3dd64809d4c24e504c77de8b8c55af3554ea4bd5643a5b3b104df8c0ac161
data/README.md CHANGED
@@ -136,6 +136,8 @@ NotionRubyMapping.configuration { |c| c.notion_token = ENV["NOTION_API_TOKEN"] }
136
136
 
137
137
  ## 3. ChangeLog
138
138
 
139
+ - 2025/10/22 [v3.0.2] Add template_page option for create_child_page and build_child_page
140
+ - 2025/10/4 [v3.0.1] Add place_property
139
141
  - 2025/9/15 [v3.0.0] updates for Notion-Version 2025-09-03 (Add DataSource class)
140
142
  - 2025/6/29 [v2.0.1] add creating FileUploadObject with external url
141
143
  - 2025/6/26 [v2.0.0] [FIX] remove symbolize_names: true (only use String)
@@ -7,7 +7,7 @@ module NotionRubyMapping
7
7
  # @param [Hash, nil] json
8
8
  # @param [String, nil] id
9
9
  # @param [Array<Property, Class, String>] assign
10
- def initialize(json: nil, id: nil, assign: [], parent: nil)
10
+ def initialize(json: nil, id: nil, assign: [], parent: nil, template_page: nil)
11
11
  @nc = NotionCache.instance
12
12
  @json = json
13
13
  @id = @nc.hex_id(id || @json && @json["id"])
@@ -16,7 +16,10 @@ module NotionRubyMapping
16
16
  @new_record = true unless parent.nil?
17
17
  raise StandardError, "Unknown id" if !is_a?(List) && !is_a?(Block) && @id.nil? && parent.nil?
18
18
 
19
- @payload = Payload.new(!is_a?(Block) && parent && {"parent" => parent})
19
+ payload_json = {}
20
+ payload_json["parent"] = parent if !is_a?(Block) && parent
21
+ payload_json["template"] = {"type" => "template_id", "template_id" => template_page.id} if template_page
22
+ @payload = Payload.new(payload_json)
20
23
  @property_cache = nil
21
24
  @created_time = nil
22
25
  @last_edited_time = nil
@@ -40,9 +40,9 @@ module NotionRubyMapping
40
40
  # @param [Array<Property, Class, String>] assign
41
41
  # @return [NotionRubyMapping::Base]
42
42
  # @see https://www.notion.so/hkob/DataSource-1462b24502424539a4231bedc07dc2f5#c217ce78020a4de79b720790fce3092d
43
- def build_child_page(*assign)
43
+ def build_child_page(*assign, template_page: nil)
44
44
  assign = properties.map { |p| [p.class, p.name] }.flatten if assign.empty?
45
- page = Page.new assign: assign, parent: {"data_source_id" => @id}
45
+ page = Page.new assign: assign, parent: {"data_source_id" => @id}, template_page: template_page
46
46
  pp = page.properties
47
47
  pp.clear_will_update
48
48
  yield page, pp if block_given?
@@ -53,9 +53,9 @@ module NotionRubyMapping
53
53
  # @param [Boolean] dry_run true if dry_run
54
54
  # @return [NotionRubyMapping::Base]
55
55
  # @see https://www.notion.so/hkob/DataSource-1462b24502424539a4231bedc07dc2f5#c217ce78020a4de79b720790fce3092d
56
- def create_child_page(*assign, dry_run: false)
56
+ def create_child_page(*assign, template_page: nil, dry_run: false)
57
57
  assign = properties.map { |p| [p.class, p.name] }.flatten if assign.empty?
58
- page = Page.new assign: assign, parent: {"data_source_id" => @id}
58
+ page = Page.new assign: assign, parent: {"data_source_id" => @id}, template_page: template_page
59
59
  pp = page.properties
60
60
  pp.clear_will_update
61
61
  yield page, pp if block_given?
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module NotionRubyMapping
4
+ # Button property
5
+ class PlaceProperty < Property
6
+ TYPE = "place"
7
+
8
+ ### Public announced methods
9
+
10
+ ## Common methods
11
+
12
+ # @return [Boolean, Hash, nil]
13
+ def place
14
+ @json
15
+ end
16
+
17
+ # @param [String, Symbol] name Property name
18
+ # @param [Boolean, Hash] json
19
+ def initialize(name, will_update: false, base_type: "page", property_id: nil, property_cache: nil, json: nil)
20
+ super name, will_update: will_update, base_type: base_type, property_id: property_id,
21
+ property_cache: property_cache
22
+ @json = json
23
+ end
24
+
25
+ ## Page property only methods
26
+
27
+ # @return [Hash]
28
+ def property_values_json
29
+ assert_page_property __method__
30
+ {@name => {"place" => @json, "type" => "place"}}
31
+ end
32
+ end
33
+ end
@@ -114,6 +114,7 @@ module NotionRubyMapping
114
114
  number: NumberProperty,
115
115
  people: PeopleProperty,
116
116
  phone_number: PhoneNumberProperty,
117
+ place: PlaceProperty,
117
118
  select: SelectProperty,
118
119
  status: StatusProperty,
119
120
  title: TitleProperty,
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NotionRubyMapping
4
- VERSION = "3.0.0"
4
+ VERSION = "3.0.2"
5
5
  NOTION_VERSION = "2025-09-03"
6
6
  end
@@ -20,7 +20,7 @@ require_relative "notion_ruby_mapping/version"
20
20
  date_property email_property files_property formula_property last_edited_by_property
21
21
  last_edited_time_property multi_select_property number_property people_property phone_number_property
22
22
  relation_property text_property rich_text_property rollup_property select_property status_property
23
- title_property unique_id_property url_property button_property verification_property],
23
+ title_property unique_id_property url_property button_property verification_property place_property],
24
24
  }.each do |key, values|
25
25
  values.each do |klass|
26
26
  require_relative "notion_ruby_mapping/#{key}/#{klass}"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: notion_ruby_mapping
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hiroyuki KOBAYASHI
@@ -255,6 +255,7 @@ files:
255
255
  - lib/notion_ruby_mapping/properties/number_property.rb
256
256
  - lib/notion_ruby_mapping/properties/people_property.rb
257
257
  - lib/notion_ruby_mapping/properties/phone_number_property.rb
258
+ - lib/notion_ruby_mapping/properties/place_property.rb
258
259
  - lib/notion_ruby_mapping/properties/property.rb
259
260
  - lib/notion_ruby_mapping/properties/relation_property.rb
260
261
  - lib/notion_ruby_mapping/properties/rich_text_property.rb