Method: Utils::CollectionViewComponents.add_new_option

Defined in:
lib/notion_api/utils.rb

.add_new_option(column, value, collection_id) ⇒ Object



562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
# File 'lib/notion_api/utils.rb', line 562

def self.add_new_option(column, value, collection_id)
  table = "collection"
  path = ["schema", column, "options"]
  command = "keyedObjectListAfter"
  colors = ["default", "gray", "brown", "orange", "yellow", "green", "blue", "purple", "pink", "red"]
  random_color = colors[rand(0...colors.length)]

  args = {
    "value": {
      "id": SecureRandom.hex(16),
      "value": value,
      "color": random_color,
    },
  }

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