diff --git a/discogs.go b/discogs.go index 3730b34..9f92a82 100644 --- a/discogs.go +++ b/discogs.go @@ -1,7 +1,6 @@ package discogs import ( - "fmt" "github.com/irlndts/go-apirequest" "net/http" ) @@ -13,18 +12,16 @@ const ( // Client is a Discogs client for making Discogs API requests. type Client struct { - api *apirequest.API - Releases *ReleaseService + api *apirequest.API + Release *ReleaseService } // NewClient returns a new Client. func NewClient(httpClient *http.Client) *Client { base := apirequest.New().Client(httpClient).Base(discogsAPI).Add("User-Agent", useragent) - fmt.Println(base) - return &Client{ - api: base, - Releases: newReleaseService(base.New()), + api: base, + Release: newReleaseService(base.New()), } } diff --git a/examples/discogs_example.go b/examples/discogs_example.go index 709509e..f010682 100644 --- a/examples/discogs_example.go +++ b/examples/discogs_example.go @@ -2,13 +2,18 @@ package main import ( "fmt" - "github.com/irlndts/go-discogs/discogs" + "github.com/irlndts/go-discogs" + // "io/ioutil" "net/http" ) func main() { client := &http.Client{} - discogs := discogs.NewClient(client) - fmt.Println(discogs) + d := discogs.NewClient(client) + params := &discogs.ReleaseParams{12345} + release, resp, err := d.Release.Release(params) + fmt.Println(release.Title) + fmt.Println(resp) + fmt.Println(err) } diff --git a/releases.go b/releases.go index 0e1ab70..db83726 100644 --- a/releases.go +++ b/releases.go @@ -2,14 +2,32 @@ package discogs import ( "github.com/irlndts/go-apirequest" + //"io/ioutil" + "net/http" ) type ReleaseService struct { api *apirequest.API } +type ReleaseParams struct { + Release_id int +} + +type Release struct { + Title string `json:"title"` + //id int + //data_quality string +} + func newReleaseService(api *apirequest.API) *ReleaseService { return &ReleaseService{ api: api.Path("releases/"), } } + +func (self *ReleaseService) Release(params *ReleaseParams) (*Release, *http.Response, error) { + release := new(Release) + resp, err := self.api.New().Get("248504").QueryStruct(params).Receive(release, nil) + return release, resp, err +}