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

34 lines
814 B
Go
Raw Normal View History

2016-03-04 16:08:02 +00:00
package discogs
import (
"net/http"
2017-02-13 16:40:27 +00:00
"github.com/irlndts/go-apirequest"
2016-03-04 16:08:02 +00:00
)
const (
2017-02-14 19:01:50 +00:00
discogsAPI = "https://api.discogs.com/"
2016-03-04 16:08:02 +00:00
)
// Client is a Discogs client for making Discogs API requests.
type Client struct {
2016-03-04 16:48:26 +00:00
api *apirequest.API
Release *ReleaseService
2016-03-10 14:25:55 +00:00
Master *MasterService
2016-03-10 14:48:15 +00:00
Artist *ArtistService
2016-03-10 15:10:08 +00:00
Label *LabelService
2017-02-13 16:40:27 +00:00
Search *SearchService
2016-03-04 16:08:02 +00:00
}
// NewClient returns a new Client.
2017-02-14 19:01:50 +00:00
func NewClient(useragent, token string) *Client {
base := apirequest.New().Client(&http.Client{}).Base(discogsAPI).Add("User-Agent", useragent).Add("Authorization", "Discogs token="+token)
2016-03-04 16:08:02 +00:00
return &Client{
2016-03-10 14:48:15 +00:00
Artist: newArtistService(base.New()),
2016-03-10 15:10:08 +00:00
Label: newLabelService(base.New()),
2017-02-13 16:40:27 +00:00
Master: newMasterService(base.New()),
Release: newReleaseService(base.New()),
2017-02-14 19:01:50 +00:00
Search: newSearchService(base.New()),
2016-03-04 16:08:02 +00:00
}
}