From 1e15cd1f9e7d782cd35b6f23db7515f891a53bc1 Mon Sep 17 00:00:00 2001 From: AaronS Date: Fri, 9 May 2025 19:37:33 -0700 Subject: [PATCH] adding sort and sort order --- README.md | 3 +++ search.go | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/README.md b/README.md index 02b0592..641928c 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,9 @@ type SearchRequest struct { Submitter string // search submitter username (optional) Contributer string // search contributor usernames (optional) + Sort string // sort results (optional) + SortOrder string // one of asc, desc (default) (optional) + Page int // optional PerPage int // optional } diff --git a/search.go b/search.go index 6a46934..a76d5bb 100644 --- a/search.go +++ b/search.go @@ -46,6 +46,9 @@ type SearchRequest struct { Submitter string // search submitter username Contributor string // search contributor usernames + Sort string // sort results + SortOrder string // one of asc, desc (default) + Page int PerPage int } @@ -112,6 +115,13 @@ func (r *SearchRequest) params() url.Values { params.Set("contributor", r.Contributor) } + if r.Sort != "" { + params.Set("sort", r.Sort) + } + if r.SortOrder != "" { + params.Set("sort_order", r.SortOrder) + } + params.Set("page", strconv.Itoa(r.Page)) if r.PerPage != 0 { params.Set("per_page", strconv.Itoa(r.PerPage))