<aside> 👉 Links (Property base class)

ButtonProperty

CreatedTimeProperty

FilesProperty

LastEditedTimeProperty

PeopleProperty

RichTextProperty

StatusProperty

UrlProperty

CheckboxProperty

DateProperty

FormulaProperty

MultiSelectProperty

PhoneNumberProperty

RollupProperty

TitleProperty

CreatedByProperty

EmailProperty

LastEditedByProperty

NumberProperty

RelationProperty 🚧

SelectProperty

UniqueIdProperty

Notion Ruby Mapping Public API Reference

</aside>

<aside> 💡

[P] means methods for Page Property, [DB/DS] means methods for Database or DataSource Property.

</aside>

1. Instance methods

files → Array<FileObject>, Hash

  1. [P] files returns the Array of FileObject.

  2. [DB/DS] files returns an empty Hash {}.

  3. A FileObject can represent an external file, a Notion hosted file, or a file uploaded with FileUploadObject.

  4. Notion hosted file URLs are temporary. Use them for reading, not for rebuilding update payloads.

    page.properties["File&MediaTitle"].files
    => [<NotionRubyMapping::FileObject:...>]
    db.properties["File&MediaTitle"].files
    => {}
    ds.properties["File&MediaTitle"].files
    => {}
    

[P] files=(value or values)

  1. [P] files=(value or values) replaces the entire files array and sets the will_update flag to true.

  2. It can accept a single external URL string, a single FileUploadObject, or an Array containing external URL strings and FileUploadObject objects.

  3. This method does not append files. To keep existing files, include them again in the assigned Array.

  4. [DB/DS] files= raises StandardError because it is only available for Page property.

    page.properties["File&MediaTitle"].files = "image url"
    => "image url"
    page.properties["File&MediaTitle"].files
    [#<NotionRubyMapping::FileObject:XXXXXXXXXXXXXXXXX
      @type="external",
      @url="image url",
      @will_update=false>]
    
    fuo = FileUploadObject fname: "test.png"
    page.properties["File&MediaTitle"].files = ["image url", fuo]
    => ["image url", fuo]
    page.properties["File&MediaTitle"].files
    [#<NotionRubyMapping::FileObject:YYYYYYYYYYYYY
      @type="external",
      @url="image url",
      @will_update=false>,
     #<NotionRubyMapping::FileObject:ZZZZZZZZZZZZZ
      @type="file_upload_object",
      @file_upload_object=#<NotionRubyMapping;:FileUploadObject:AAAAAAAAAAAAAAAA,
      @will_update=false>]
    
    page.properties["File&MediaTitle"].files = []
    => []
    
    db.properties["File&MediaTitle"].files = "image url"
    # ...:in `assert_page_property': files= can execute only Page property. (StandardError)
    

[P] file_names=(value or values)

  1. [P] file_names=(value or values) replaces the display names of files and sets the will_update flag to true.

  2. The number of file names must match the number of files.

  3. If the number of file names does not match the number of files, it raises ArgumentError.

  4. For external URL files, the default name is the URL string. For FileUploadObject, the default name is fname.

    page.properties["File&MediaTitle"].files = ["image url 1", "image url 2"]
    => ["image url 1", "image url 2"]
    
    page.properties["File&MediaTitle"].file_names = ["image1.png", "image2.png"]
    => ["image1.png", "image2.png"]
    
    page.properties["File&MediaTitle"].file_names = ["image1.png"]
    # ...:in `file_names=': files and file_names must be the same sizes. (ArgumentError)