Label Releases block added
This commit is contained in:
parent
3cd62fafbb
commit
0a6c18bb45
@ -126,3 +126,15 @@ type Sublable struct {
|
|||||||
Id int `json:"id"`
|
Id int `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ReleaseSource struct {
|
||||||
|
Artist string `json:"artist"`
|
||||||
|
Catno string `json:"catno"`
|
||||||
|
Format string `json:"format"`
|
||||||
|
Id int `json:"id"`
|
||||||
|
Resource_url string `json:"resource_url"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
Thumb string `json:"thumb"`
|
||||||
|
Title string `json:"title"`
|
||||||
|
Year int `json:"year"`
|
||||||
|
}
|
||||||
|
@ -15,13 +15,13 @@ func main() {
|
|||||||
release, _, err := d.Release.Release(params)
|
release, _, err := d.Release.Release(params)
|
||||||
*/
|
*/
|
||||||
params := &discogs.LabelParams{Label_id: "1000"}
|
params := &discogs.LabelParams{Label_id: "1000"}
|
||||||
label, _, err := d.Label.Label(params)
|
label, _, err := d.Label.Releases(params)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
} else {
|
} else {
|
||||||
//fmt.Println(release.Title)
|
//fmt.Println(release.Title)
|
||||||
fmt.Println(label.Name)
|
fmt.Println(label.Releases[0].Title)
|
||||||
}
|
}
|
||||||
//fmt.Println(resp)
|
//fmt.Println(resp)
|
||||||
}
|
}
|
||||||
|
15
labels.go
15
labels.go
@ -11,6 +11,8 @@ type LabelService struct {
|
|||||||
|
|
||||||
type LabelParams struct {
|
type LabelParams struct {
|
||||||
Label_id string
|
Label_id string
|
||||||
|
Page int
|
||||||
|
Per_page int
|
||||||
}
|
}
|
||||||
|
|
||||||
type Label struct {
|
type Label struct {
|
||||||
@ -27,6 +29,11 @@ type Label struct {
|
|||||||
Data_quality string `json:"data_quality"`
|
Data_quality string `json:"data_quality"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type LabelReleases struct {
|
||||||
|
Pagination Page `json:"pagination"`
|
||||||
|
Releases []ReleaseSource `json:"releases"`
|
||||||
|
}
|
||||||
|
|
||||||
func newLabelService(api *apirequest.API) *LabelService {
|
func newLabelService(api *apirequest.API) *LabelService {
|
||||||
return &LabelService{
|
return &LabelService{
|
||||||
api: api.Path("labels/"),
|
api: api.Path("labels/"),
|
||||||
@ -40,3 +47,11 @@ func (self *LabelService) Label(params *LabelParams) (*Label, *http.Response, er
|
|||||||
resp, err := self.api.New().Get(params.Label_id).Receive(label, apiError)
|
resp, err := self.api.New().Get(params.Label_id).Receive(label, apiError)
|
||||||
return label, resp, relevantError(err, *apiError)
|
return label, resp, relevantError(err, *apiError)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self *LabelService) Releases(params *LabelParams) (*LabelReleases, *http.Response, error) {
|
||||||
|
releases := new(LabelReleases)
|
||||||
|
apiError := new(APIError)
|
||||||
|
|
||||||
|
resp, err := self.api.New().Get(params.Label_id+"/releases").QueryStruct(params).Receive(releases, apiError)
|
||||||
|
return releases, resp, relevantError(err, *apiError)
|
||||||
|
}
|
||||||
|
@ -16,3 +16,14 @@ func TestLabelService_Label(t *testing.T) {
|
|||||||
check(t, err)
|
check(t, err)
|
||||||
assert(t, label.Id == expectedId, fmt.Sprintf("Release.Title looked for %s, and received %s ", expectedId, label.Id))
|
assert(t, label.Id == expectedId, fmt.Sprintf("Release.Title looked for %s, and received %s ", expectedId, label.Id))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestLabelService_Releases(t *testing.T) {
|
||||||
|
expectedId := "Good Time"
|
||||||
|
|
||||||
|
client := &http.Client{}
|
||||||
|
d := NewClient(client).UserAgent("UnitTestClient/0.0.1 +https://github.com/irlndts/go-discogs")
|
||||||
|
label, _, err := d.Label.Releases(&LabelParams{Label_id: "1000"})
|
||||||
|
|
||||||
|
check(t, err)
|
||||||
|
assert(t, label.Releases[0].Title == expectedId, fmt.Sprintf("Release.Title looked for %s, and received %s ", expectedId, label.Releases[0].Title))
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user