Rating
This commit is contained in:
parent
69ef2a5d9a
commit
4a80c3cc39
@ -17,10 +17,10 @@ func main() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
release, err := d.Release.Release(9893847)
|
release, err := d.Release.Rating(9893847)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fmt.Printf("%+v\n", release.Title)
|
fmt.Printf("%+v\n", release)
|
||||||
}
|
}
|
||||||
|
51
releases.go
51
releases.go
@ -5,6 +5,24 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// ReleaseService ...
|
||||||
|
type ReleaseService struct {
|
||||||
|
url string
|
||||||
|
currency string
|
||||||
|
}
|
||||||
|
|
||||||
|
func newReleaseService(url string, currency string) *ReleaseService {
|
||||||
|
return &ReleaseService{
|
||||||
|
url: url,
|
||||||
|
currency: currency,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReqRelease serves release request
|
||||||
|
type ReqRelease struct {
|
||||||
|
CurrAbbr string
|
||||||
|
}
|
||||||
|
|
||||||
// Release serves relesase response from discogs
|
// Release serves relesase response from discogs
|
||||||
type Release struct {
|
type Release struct {
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
@ -42,23 +60,6 @@ type Release struct {
|
|||||||
Year int `json:"year"`
|
Year int `json:"year"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ReqRelease struct {
|
|
||||||
CurrAbbr string
|
|
||||||
}
|
|
||||||
|
|
||||||
// ReleaseService ...
|
|
||||||
type ReleaseService struct {
|
|
||||||
url string
|
|
||||||
currency string
|
|
||||||
}
|
|
||||||
|
|
||||||
func newReleaseService(url string, currency string) *ReleaseService {
|
|
||||||
return &ReleaseService{
|
|
||||||
url: url,
|
|
||||||
currency: currency,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Release returns release by release's ID
|
// Release returns release by release's ID
|
||||||
func (s *ReleaseService) Release(releaseID int) (*Release, error) {
|
func (s *ReleaseService) Release(releaseID int) (*Release, error) {
|
||||||
params := url.Values{}
|
params := url.Values{}
|
||||||
@ -71,3 +72,19 @@ func (s *ReleaseService) Release(releaseID int) (*Release, error) {
|
|||||||
|
|
||||||
return release, nil
|
return release, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ReleaseRating serves response for community release rating request
|
||||||
|
type ReleaseRating struct {
|
||||||
|
ID int `json:"release_id"`
|
||||||
|
Rating Rating `json:"rating"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ratings retruns community release rating
|
||||||
|
func (s *ReleaseService) Rating(releaseID int) (*ReleaseRating, error) {
|
||||||
|
var rating *ReleaseRating
|
||||||
|
if err := request(s.url+strconv.Itoa(releaseID)+"/rating", nil, &rating); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return rating, nil
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user