1
0
mirror of https://github.com/dstotijn/go-notion.git synced 2025-06-06 23:36:14 +02:00

Fix faulty search sort type, add consts for sort props

This commit is contained in:
David Stotijn 2021-05-27 20:50:04 +02:00
parent 132dd31efd
commit 5197b070b9

View File

@ -7,17 +7,19 @@ import (
type SearchOpts struct {
Query string `json:"query,omitempty"`
Sort *SearchFilter `json:"sort,omitempty"`
Sort *SearchSort `json:"sort,omitempty"`
Filter *SearchFilter `json:"filter,omitempty"`
StartCursor string `json:"start_cursor,omitempty"`
PageSize int `json:"page_size,omitempty"`
}
type SearchSort struct {
Direction SortDirection `json:"direction,omitempty"`
Timestamp string `json:"timestamp"`
Direction SortDirection `json:"direction,omitempty"`
Timestamp SearchSortTimestamp `json:"timestamp"`
}
type SearchSortTimestamp string
type SearchFilter struct {
Value string `json:"value"`
Property string `json:"property"`
@ -32,6 +34,8 @@ type SearchResponse struct {
type SearchResults []interface{}
const SearchSortTimestampLastEditedTime SearchSortTimestamp = "last_edited_time"
func (sr *SearchResults) UnmarshalJSON(b []byte) error {
rawResults := []json.RawMessage{}
err := json.Unmarshal(b, &rawResults)