Method: Utils::CollectionViewComponents.update_property_value

Defined in:
lib/notion_api/utils.rb

.update_property_value(page_id, column_name, new_value, column_type) ⇒ Object



642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
# File 'lib/notion_api/utils.rb', line 642

def self.update_property_value(page_id, column_name, new_value, column_type)
  # ! update the specified column_name to new_value
  # ! page_id -> the ID of the page: ``str``
  # ! column_name -> the name of the column ["property"] to update: ``str``
  # ! new_value -> the new value to assign to that column ["property"]: ``str``
  # ! column_type -> the type of the property: ``str``
  table = "block"
  path = [
    "properties",
    column_name,
  ]
  command = "set"

  if column_type == "relation"
    args = [["", [[
      "p", new_value,
    ]]]]
  else
    args = [[
      new_value,
    ]]
  end

  {
    id: page_id,
    table: table,
    path: path,
    command: command,
    args: args,
  }
end