From 0b91e1c5aaa57eb7c7f2a4eac14d0b48713716c4 Mon Sep 17 00:00:00 2001 From: Tanner Date: Tue, 19 Nov 2024 09:59:53 -0500 Subject: [PATCH] Issue #8 - Add StartCursor To Index (#9) --- index.go | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/index.go b/index.go index 05d604a..473680b 100644 --- a/index.go +++ b/index.go @@ -32,13 +32,12 @@ type IndexQueryParameters struct { Jvndb string `json:"jvndb"` // PAGINATION RELATED - Limit int `json:"limit"` - Sort string `json:"sort"` - Order string `json:"order"` - Page int `json:"page"` - Cursor string `json:"cursor"` - NextCursor string `json:"next_cursor"` - PrevCursor string `json:"prev_cursor"` // this may not exist + Limit int `json:"limit"` + Sort string `json:"sort"` + Order string `json:"order"` + Page int `json:"page"` + StartCursor bool `json:"start_cursor"` + Cursor string `json:"cursor"` } type IndexMeta struct { @@ -54,6 +53,7 @@ type IndexMeta struct { MaxPages int `json:"max_pages"` FirstItem int `json:"first_item"` LastItem int `json:"last_item"` + NextCursor string `json:"next_cursor"` } type IndexMetaParameters struct { @@ -147,14 +147,12 @@ func setIndexQueryParameters(query url.Values, queryParameters ...IndexQueryPara if queryParameter.Page != 0 { query.Add("page", fmt.Sprintf("%d", queryParameter.Page)) } + if queryParameter.StartCursor { + query.Add("start_cursor", fmt.Sprintf("%t", queryParameter.StartCursor)) + } if queryParameter.Cursor != "" { query.Add("cursor", queryParameter.Cursor) - } - if queryParameter.NextCursor != "" { - query.Add("next_cursor", queryParameter.NextCursor) - } - if queryParameter.PrevCursor != "" { - query.Add("prev_cursor", queryParameter.PrevCursor) + query.Del("start_cursor") // cursor and start_cursor are mutually exclusive } } }