2016-03-10 15:10:08 +00:00
|
|
|
package discogs
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
2017-02-13 16:40:27 +00:00
|
|
|
|
|
|
|
"github.com/irlndts/go-apirequest"
|
2016-03-10 15:10:08 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type LabelService struct {
|
|
|
|
api *apirequest.API
|
|
|
|
}
|
|
|
|
|
|
|
|
type LabelParams struct {
|
2017-02-13 16:40:27 +00:00
|
|
|
LabelID string
|
|
|
|
Page int
|
|
|
|
PerPage int
|
2016-03-10 15:10:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type Label struct {
|
2017-02-13 16:40:27 +00:00
|
|
|
Profile string `json:"profile"`
|
|
|
|
ReleasesUrl string `json:"releases_url"`
|
|
|
|
Name string `json:"name"`
|
|
|
|
ContactInfo string `json:"contact_info"`
|
|
|
|
Uri string `json:"uri"`
|
|
|
|
Sublabels []Sublable `json:"sublabels"`
|
|
|
|
Urls []string `json:"urls"`
|
|
|
|
Images []Image `json:"images"`
|
|
|
|
ResourceUrl string `json:"resource_url"`
|
|
|
|
Id int `json:"id"`
|
|
|
|
DataQuality string `json:"data_quality"`
|
2016-03-10 15:10:08 +00:00
|
|
|
}
|
|
|
|
|
2016-03-10 15:26:39 +00:00
|
|
|
type LabelReleases struct {
|
|
|
|
Pagination Page `json:"pagination"`
|
|
|
|
Releases []ReleaseSource `json:"releases"`
|
|
|
|
}
|
|
|
|
|
2016-03-10 15:10:08 +00:00
|
|
|
func newLabelService(api *apirequest.API) *LabelService {
|
|
|
|
return &LabelService{
|
|
|
|
api: api.Path("labels/"),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (self *LabelService) Label(params *LabelParams) (*Label, *http.Response, error) {
|
|
|
|
label := new(Label)
|
|
|
|
apiError := new(APIError)
|
|
|
|
|
2017-02-13 16:40:27 +00:00
|
|
|
resp, err := self.api.New().Get(params.LabelID).Receive(label, apiError)
|
2016-03-10 15:10:08 +00:00
|
|
|
return label, resp, relevantError(err, *apiError)
|
|
|
|
}
|
2016-03-10 15:26:39 +00:00
|
|
|
|
|
|
|
func (self *LabelService) Releases(params *LabelParams) (*LabelReleases, *http.Response, error) {
|
|
|
|
releases := new(LabelReleases)
|
|
|
|
apiError := new(APIError)
|
|
|
|
|
2017-02-13 16:40:27 +00:00
|
|
|
resp, err := self.api.New().Get(params.LabelID+"/releases").QueryStruct(params).Receive(releases, apiError)
|
2016-03-10 15:26:39 +00:00
|
|
|
return releases, resp, relevantError(err, *apiError)
|
|
|
|
}
|