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