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/artists.go
2018-03-12 21:13:09 +03:00

53 lines
1.4 KiB
Go

package discogs
import "strconv"
// ArtistService ...
type ArtistService struct {
url string
}
func newArtistService(url string) *ArtistService {
return &ArtistService{
url: url,
}
}
// Artist ...
type Artist struct {
Namevariations []string `json:"namevariations"`
Profile string `json:"profile"`
Releases_url string `json:"releases_url"`
Resource_url string `json:"resource_url"`
Uri string `json:"uri"`
Urls []string `json:"urls"`
Data_quality string `json:"data_quality"`
Id int `json:"id"`
Images []Image `json:"images"`
Members []Member `json:"members"`
}
// Artist represents a person in the discogs database
func (s *ArtistService) Artist(artistID int) (*Artist, error) {
var artist *Artist
if err := request(s.url+strconv.Itoa(artistID), nil, &artist); err != nil {
return nil, err
}
return artist, nil
}
// ArtistReleases ...
type ArtistReleases struct {
Pagination Page `json:"pagination"`
Releases []ReleaseSource `json:"releases"`
}
// Releases returns a list of releases and masters associated with the artist.
func (s *ArtistService) Releases(artistID int, pagination *Pagination) (*ArtistReleases, error) {
var releases *ArtistReleases
if err := request(s.url+strconv.Itoa(artistID)+"/releases", pagination.toParams(), &releases); err != nil {
return nil, err
}
return releases, nil
}