From 7885a06b95533795e9a656c5a0013faa47a11a04 Mon Sep 17 00:00:00 2001 From: irlndts Date: Fri, 4 Mar 2016 19:08:02 +0300 Subject: [PATCH] tmp --- discogs.go | 30 ++++++++++++++++++++++++++++++ examples/discogs_example.go | 14 ++++++++++++++ releases.go | 15 +++++++++++++++ 3 files changed, 59 insertions(+) create mode 100644 discogs.go create mode 100644 examples/discogs_example.go create mode 100644 releases.go diff --git a/discogs.go b/discogs.go new file mode 100644 index 0000000..3730b34 --- /dev/null +++ b/discogs.go @@ -0,0 +1,30 @@ +package discogs + +import ( + "fmt" + "github.com/irlndts/go-apirequest" + "net/http" +) + +const ( + discogsAPI = "https://api.discogs.com/" + useragent = "TestDiscogsClient/0.0.1 +http://irlndts.moscow" +) + +// Client is a Discogs client for making Discogs API requests. +type Client struct { + api *apirequest.API + Releases *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()), + } +} diff --git a/examples/discogs_example.go b/examples/discogs_example.go new file mode 100644 index 0000000..709509e --- /dev/null +++ b/examples/discogs_example.go @@ -0,0 +1,14 @@ +package main + +import ( + "fmt" + "github.com/irlndts/go-discogs/discogs" + "net/http" +) + +func main() { + client := &http.Client{} + discogs := discogs.NewClient(client) + fmt.Println(discogs) + +} diff --git a/releases.go b/releases.go new file mode 100644 index 0000000..0e1ab70 --- /dev/null +++ b/releases.go @@ -0,0 +1,15 @@ +package discogs + +import ( + "github.com/irlndts/go-apirequest" +) + +type ReleaseService struct { + api *apirequest.API +} + +func newReleaseService(api *apirequest.API) *ReleaseService { + return &ReleaseService{ + api: api.Path("releases/"), + } +}