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/labels.go

57 lines
1.5 KiB
Go
Raw Permalink Normal View History

2016-03-10 15:10:08 +00:00
package discogs
import (
2018-03-12 20:31:47 +00:00
"strconv"
2016-03-10 15:10:08 +00:00
)
2018-03-12 20:31:47 +00:00
// LabelService ...
2016-03-10 15:10:08 +00:00
type LabelService struct {
2018-03-12 20:31:47 +00:00
url string
2016-03-10 15:10:08 +00:00
}
2018-03-12 20:31:47 +00:00
func newLabelService(url string) *LabelService {
return &LabelService{
url: url,
}
2016-03-10 15:10:08 +00:00
}
2018-03-12 20:31:47 +00:00
// Label resource represents a label, company, recording studio, location,
// or other entity involved with artists and releases.
2016-03-10 15:10:08 +00:00
type Label struct {
2018-03-12 20:31:47 +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
}
2018-03-12 20:31:47 +00:00
// Label returns a label.
func (s *LabelService) Label(labelID int) (*Label, error) {
var label *Label
if err := request(s.url+strconv.Itoa(labelID), nil, &label); err != nil {
return nil, err
}
return label, nil
}
// LabelReleases is a list of Releases associated with the label.
2016-03-10 15:26:39 +00:00
type LabelReleases struct {
Pagination Page `json:"pagination"`
Releases []ReleaseSource `json:"releases"`
}
2018-03-12 20:31:47 +00:00
// Releases returns a list of Releases associated with the label.
func (s *LabelService) Releases(labelID int, pagination *Pagination) (*LabelReleases, error) {
var releases *LabelReleases
if err := request(s.url+strconv.Itoa(labelID)+"/releases", pagination.toParams(), &releases); err != nil {
return nil, err
2016-03-10 15:10:08 +00:00
}
2018-03-12 20:31:47 +00:00
return releases, nil
2016-03-10 15:26:39 +00:00
}