Specify 'offset' as page number in GetTerms() definition

This commit is contained in:
2024-02-16 17:03:23 -06:00
parent d22b3a30a3
commit 7ce28b9f4a

11
api.go
View File

@@ -30,21 +30,22 @@ func (term BannerTerm) Archived() bool {
}
// GetTerms retrieves and parses the term information for a given search term.
// Ensure that the offset is greater than 0.
func GetTerms(search string, offset int, max int) ([]BannerTerm, error) {
// Page number must be at least 1.
func GetTerms(search string, page int, max int) ([]BannerTerm, error) {
// Ensure offset is valid
if offset <= 0 {
if page <= 0 {
return nil, errors.New("offset must be greater than 0")
}
req := BuildRequest("GET", "/classSearch/getTerms", map[string]string{
"searchTerm": search,
"offset": strconv.Itoa(offset),
// Page vs Offset is not a mistake here, the API uses "offset" as the page number
"offset": strconv.Itoa(page),
"max": strconv.Itoa(max),
"_": Nonce(),
})
if offset <= 0 {
if page <= 0 {
return nil, errors.New("Offset must be greater than 0")
}