5am-code / laravel-notion-api

Effortless Notion integrations with Laravel
https://notionforlaravel.com
MIT License
410 stars 50 forks source link

sortByLastEditedTime replace with sortByCreatedTime #149

Closed DevKylian closed 1 year ago

DevKylian commented 1 year ago

Hello,

I want to sort my Search with Created Time and not the Last Edited Time.

In the Search class, I've created another method :

/**
   * @param  string  $direction
   * @return $this
   */
  public function sortByCreatedTime(string $direction = 'ascending'): Search
  {
      $this->sort = Sorting::timestampSort('created_time', $direction);

      return $this;
  }

But I receive this error :

Bad Request: (validation_error) (body failed validation: body.sort.timestamp should be "last_edited_time", instead was "created_time".)

johguentner commented 1 year ago

Hi @DevKylian, this is a Bad Request error, which you receive directly from the Notion API.

As of today, the only supported sorting attribute is last_edited_time for the Search endpoint: https://developers.notion.com/reference/post-search