This repository has been archived on 2023-04-13. You can view files and clone it, but cannot push or open issues or pull requests.
go-discogs/search.go

39 lines
737 B
Go
Raw Normal View History

2017-02-13 16:40:27 +00:00
package discogs
import (
"net/http"
"github.com/irlndts/go-apirequest"
)
type SearchRequest struct {
Release_title string
Artist string
Page int
PerPage int
}
type Search struct {
Pagination Page `json:"pagination"`
Results []interface{} `json:"results"`
}
type SearchService struct {
api *apirequest.API
}
func newSearchService(api *apirequest.API) *SearchService {
return &SearchService{
api: api.Path("database/search"),
}
}
func (self *SearchService) Search(params *SearchRequest) (*Search, *http.Response, error) {
search := new(Search)
apiError := new(APIError)
resp, err := self.api.QueryStruct(params).Receive(search, apiError)
return search, resp, relevantError(err, *apiError)
}