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

60 lines
1.8 KiB
Go
Raw Normal View History

2016-03-10 14:25:55 +00:00
package discogs
import (
2018-03-12 18:13:09 +00:00
"strconv"
2016-03-10 14:25:55 +00:00
)
type MasterService struct {
2018-03-12 18:13:09 +00:00
url string
2016-03-10 14:25:55 +00:00
}
2018-03-12 18:13:09 +00:00
func newMasterService(url string) *MasterService {
return &MasterService{
url: url,
}
2016-03-10 14:25:55 +00:00
}
2018-03-12 18:13:09 +00:00
// Master resource represents a set of similar releases.
// Masters (also known as `master releases`) have a `main release` which is often the chronologically earliest.
2016-03-10 14:25:55 +00:00
type Master struct {
Styles []string `json:"styles"`
Genres []string `json:"genres"`
Videos []Video `json:"videos"`
Title string `json:"title"`
Main_release int `json:"main_release"`
Main_release_url string `json:"main_release_url"`
Uri string `json:"uri"`
Artists []Artist `json:"artists"`
Version_url string `json:"version_url"`
Year int `json:"year"`
Images []Image `json:"images"`
Resource_url string `json:"resource_url"`
Tracklist []Track `json:"tracklist"`
Id int `json:"id"`
Data_quality string `json:"data_quality"`
}
2018-03-12 18:13:09 +00:00
// Master returns a master release
func (s *MasterService) Master(masterID int) (*Master, error) {
var master *Master
if err := request(s.url+strconv.Itoa(masterID), nil, &master); err != nil {
return nil, err
}
return master, nil
}
// MasterVersions retrieves a list of all releases that are versions of this master.
2016-03-10 14:25:55 +00:00
type MasterVersions struct {
Pagination Page `json:"pagination"`
Versions []Version `json:"versions"`
}
2018-03-12 18:13:09 +00:00
// Versions retrieves a list of all Releases that are versions of this master
func (s *MasterService) Versions(masterID int, pagination *Pagination) (*MasterVersions, error) {
var versions *MasterVersions
if err := request(s.url+strconv.Itoa(masterID)+"/versions", pagination.toParams(), &versions); err != nil {
return nil, err
2016-03-10 14:25:55 +00:00
}
2018-03-12 18:13:09 +00:00
return versions, nil
2016-03-10 14:25:55 +00:00
}