Artist Releases block
This commit is contained in:
parent
0a6c18bb45
commit
de1e81b89d
17
artists.go
17
artists.go
@ -11,6 +11,10 @@ type ArtistService struct {
|
|||||||
|
|
||||||
type ArtistParams struct {
|
type ArtistParams struct {
|
||||||
Artist_id string
|
Artist_id string
|
||||||
|
Sort string // year, title, format
|
||||||
|
Sort_order string // asc, desc
|
||||||
|
Page int
|
||||||
|
Per_page int
|
||||||
}
|
}
|
||||||
|
|
||||||
type Artist struct {
|
type Artist struct {
|
||||||
@ -26,6 +30,11 @@ type Artist struct {
|
|||||||
Members []Member `json:"members"`
|
Members []Member `json:"members"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ArtistReleases struct {
|
||||||
|
Paginastion Page `json:"pagination"`
|
||||||
|
Releases []ReleaseSource `json:"releases"`
|
||||||
|
}
|
||||||
|
|
||||||
func newArtistService(api *apirequest.API) *ArtistService {
|
func newArtistService(api *apirequest.API) *ArtistService {
|
||||||
return &ArtistService{
|
return &ArtistService{
|
||||||
api: api.Path("artists/"),
|
api: api.Path("artists/"),
|
||||||
@ -39,3 +48,11 @@ func (self *ArtistService) Artist(params *ArtistParams) (*Artist, *http.Response
|
|||||||
resp, err := self.api.New().Get(params.Artist_id).Receive(artist, apiError)
|
resp, err := self.api.New().Get(params.Artist_id).Receive(artist, apiError)
|
||||||
return artist, resp, relevantError(err, *apiError)
|
return artist, resp, relevantError(err, *apiError)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self *ArtistService) Releases(params *ArtistParams) (*ArtistReleases, *http.Response, error) {
|
||||||
|
releases := new(ArtistReleases)
|
||||||
|
apiError := new(APIError)
|
||||||
|
|
||||||
|
resp, err := self.api.New().Get(params.Artist_id+"/releases").QueryStruct(params).Receive(releases, apiError)
|
||||||
|
return releases, resp, relevantError(err, *apiError)
|
||||||
|
}
|
||||||
|
@ -16,3 +16,14 @@ func TestArtistService_Artist(t *testing.T) {
|
|||||||
check(t, err)
|
check(t, err)
|
||||||
assert(t, artist.Id == expectedId, fmt.Sprintf("Release.Title looked for %s, and received %s ", expectedId, artist.Id))
|
assert(t, artist.Id == expectedId, fmt.Sprintf("Release.Title looked for %s, and received %s ", expectedId, artist.Id))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestArtistService_Releases(t *testing.T) {
|
||||||
|
expectedArtist := "Dave Clarke"
|
||||||
|
|
||||||
|
client := &http.Client{}
|
||||||
|
d := NewClient(client).UserAgent("UnitTestClient/0.0.1 +https://github.com/irlndts/go-discogs")
|
||||||
|
releases, _, err := d.Artist.Releases(&ArtistParams{Artist_id: "1000", Sort: "year", Sort_order: "desc"})
|
||||||
|
|
||||||
|
check(t, err)
|
||||||
|
assert(t, releases.Releases[0].Artist == expectedArtist, fmt.Sprintf("Releses.Artist looked for %s, and received %s ", expectedArtist, releases.Releases[0].Artist))
|
||||||
|
}
|
||||||
|
@ -137,4 +137,7 @@ type ReleaseSource struct {
|
|||||||
Thumb string `json:"thumb"`
|
Thumb string `json:"thumb"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
Year int `json:"year"`
|
Year int `json:"year"`
|
||||||
|
Main_release int `json:"main_release"`
|
||||||
|
Role string `json:"role"`
|
||||||
|
Type string `json:"type"`
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user