DSCGS-4 enough for today
This commit is contained in:
		@@ -41,10 +41,9 @@ client := discogs.NewClient("TestDiscogsClient/0.0.1 +example.com", "sometoken")
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#### Releases
 | 
					#### Releases
 | 
				
			||||||
```go
 | 
					```go
 | 
				
			||||||
  params := &discogs.ReleaseParams{Release_id: "8138518"}
 | 
					  release, err := client.Release.Release(9893847)
 | 
				
			||||||
  release, _, err := client.Release.Release(params)
 | 
					 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  fmt.Println(fmt.Println(release.Artists[0].Name, " - ", release.Title)) // St. Petersburg Ska-Jazz Review  -  Elephant Riddim
 | 
					  fmt.Println(release.Artists[0].Name, " - ", release.Title) // St. Petersburg Ska-Jazz Review  -  Elephant Riddim
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#### Artists
 | 
					#### Artists
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										47
									
								
								discogs.go
									
									
									
									
									
								
							
							
						
						
									
										47
									
								
								discogs.go
									
									
									
									
									
								
							@@ -12,22 +12,47 @@ const (
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// Client is a Discogs client for making Discogs API requests.
 | 
					// Client is a Discogs client for making Discogs API requests.
 | 
				
			||||||
type Client struct {
 | 
					type Client struct {
 | 
				
			||||||
	api     *apirequest.API
 | 
						api      *apirequest.API
 | 
				
			||||||
	Release *ReleaseService
 | 
						currency string
 | 
				
			||||||
	Master  *MasterService
 | 
						//Release *ReleaseService
 | 
				
			||||||
	Artist  *ArtistService
 | 
						Master *MasterService
 | 
				
			||||||
	Label   *LabelService
 | 
						Artist *ArtistService
 | 
				
			||||||
	Search  *SearchService
 | 
						Label  *LabelService
 | 
				
			||||||
 | 
						Search *SearchService
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// NewClient returns a new Client.
 | 
					// NewClient returns a new Client.
 | 
				
			||||||
func NewClient(useragent, token string) *Client {
 | 
					func NewClient(useragent, token string) *Client {
 | 
				
			||||||
	base := apirequest.New().Client(&http.Client{}).Base(discogsAPI).Add("User-Agent", useragent).Add("Authorization", "Discogs token="+token)
 | 
						base := apirequest.New().Client(&http.Client{}).Base(discogsAPI).Add("User-Agent", useragent).Add("Authorization", "Discogs token="+token)
 | 
				
			||||||
	return &Client{
 | 
						return &Client{
 | 
				
			||||||
		Artist:  newArtistService(base.New()),
 | 
							api:      base,
 | 
				
			||||||
		Label:   newLabelService(base.New()),
 | 
							currency: "USD",
 | 
				
			||||||
		Master:  newMasterService(base.New()),
 | 
					
 | 
				
			||||||
		Release: newReleaseService(base.New()),
 | 
							Artist: newArtistService(base.New()),
 | 
				
			||||||
		Search:  newSearchService(base.New()),
 | 
							Label:  newLabelService(base.New()),
 | 
				
			||||||
 | 
							Master: newMasterService(base.New()),
 | 
				
			||||||
 | 
							//Release: newReleaseService(base.New()),
 | 
				
			||||||
 | 
							Search: newSearchService(base.New()),
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Token sets tokens, it's required for some queries like search
 | 
				
			||||||
 | 
					func (c *Client) Token(token string) *Client {
 | 
				
			||||||
 | 
						c.api.Set("Authorization", "Discogs token="+token)
 | 
				
			||||||
 | 
						return c
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// UserAgent sets specified user agent
 | 
				
			||||||
 | 
					// Discogs requires it
 | 
				
			||||||
 | 
					func (c *Client) UserAgent(useragent string) *Client {
 | 
				
			||||||
 | 
						c.api.Set("User-Agent", useragent)
 | 
				
			||||||
 | 
						return c
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// SetCurrency determines currency for marketplace data.
 | 
				
			||||||
 | 
					// Defaults to the authenticated users currency. Must be one of the following:
 | 
				
			||||||
 | 
					// USD GBP EUR CAD AUD JPY CHF MXN BRL NZD SEK ZAR
 | 
				
			||||||
 | 
					func (c *Client) Currency(currency string) error {
 | 
				
			||||||
 | 
						c.currency = currency
 | 
				
			||||||
 | 
						return nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,7 +9,7 @@ import (
 | 
				
			|||||||
func main() {
 | 
					func main() {
 | 
				
			||||||
	d := discogs.NewClient("TestDiscogsClient/0.0.1 +http://irlndts.moscow", "")
 | 
						d := discogs.NewClient("TestDiscogsClient/0.0.1 +http://irlndts.moscow", "")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	request := &discogs.SearchRequest{Q: "The Reggaenauts - River Rock / Thursday Kick-off", Page: 0, Per_page: 1}
 | 
						request := &discogs.SearchRequest{Q: "The Swindlers - Dig Out Alive!", Page: 0, Per_page: 1}
 | 
				
			||||||
	search, _, err := d.Search.Search(request)
 | 
						search, _, err := d.Search.Search(request)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
@@ -18,6 +18,12 @@ func main() {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for _, r := range search.Results {
 | 
						for _, r := range search.Results {
 | 
				
			||||||
		fmt.Println(r.Id, r.Title)
 | 
							fmt.Printf("%+v\n", r)
 | 
				
			||||||
 | 
							//fmt.Println(r.Id, r.Title)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							release, _ := d.Release(r.ID)
 | 
				
			||||||
 | 
							fmt.Printf("%+v\n", release)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -16,7 +16,7 @@ func TestLabelService_Label(t *testing.T) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func TestLabelService_Releases(t *testing.T) {
 | 
					func TestLabelService_Releases(t *testing.T) {
 | 
				
			||||||
	expectedId := "Cha Cha Twist"
 | 
						expectedId := "Ghetto Sol"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	d := NewClient(testUserAgent, testToken)
 | 
						d := NewClient(testUserAgent, testToken)
 | 
				
			||||||
	label, _, err := d.Label.Releases(&LabelParams{Label_id: "1000"})
 | 
						label, _, err := d.Label.Releases(&LabelParams{Label_id: "1000"})
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										89
									
								
								releases.go
									
									
									
									
									
								
							
							
						
						
									
										89
									
								
								releases.go
									
									
									
									
									
								
							@@ -1,61 +1,56 @@
 | 
				
			|||||||
package discogs
 | 
					package discogs
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"github.com/irlndts/go-apirequest"
 | 
						"strconv"
 | 
				
			||||||
	"net/http"
 | 
					 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type ReleaseService struct {
 | 
					// Release serves relesase response from discogs
 | 
				
			||||||
	api *apirequest.API
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
type ReleaseParams struct {
 | 
					 | 
				
			||||||
	Release_id string
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
type Release struct {
 | 
					type Release struct {
 | 
				
			||||||
	Title              string         `json:"title"`
 | 
						Title             string         `json:"title"`
 | 
				
			||||||
	Id                 int            `json:"id"`
 | 
						ID                int            `json:"id"`
 | 
				
			||||||
	Artists            []ArtistSource `json:"artists"`
 | 
						Artists           []ArtistSource `json:"artists"`
 | 
				
			||||||
	Data_quality       string         `json:"data_quality"`
 | 
						DataQuality       string         `json:"data_quality"`
 | 
				
			||||||
	Thumb              string         `json:"thumb"`
 | 
						Thumb             string         `json:"thumb"`
 | 
				
			||||||
	Community          Community      `json:"community"`
 | 
						Community         Community      `json:"community"`
 | 
				
			||||||
	Companies          []Company      `json:"companies"`
 | 
						Companies         []Company      `json:"companies"`
 | 
				
			||||||
	Country            string         `json:"country"`
 | 
						Country           string         `json:"country"`
 | 
				
			||||||
	Date_added         string         `json:"date_added"`
 | 
						DateAdded         string         `json:"date_added"`
 | 
				
			||||||
	Date_changed       string         `json:"date_changed"`
 | 
						DateChanged       string         `json:"date_changed"`
 | 
				
			||||||
	Estimated_weight   int            `json:"estimated_weight"`
 | 
						EstimatedWeight   int            `json:"estimated_weight"`
 | 
				
			||||||
	Extraartists       []ArtistSource `json:"extraartists"`
 | 
						ExtraArtists      []ArtistSource `json:"extraartists"`
 | 
				
			||||||
	Format_quantity    int            `json:"format_quantity"`
 | 
						FormatQuantity    int            `json:"format_quantity"`
 | 
				
			||||||
	Formats            []Format       `json:"formats"`
 | 
						Formats           []Format       `json:"formats"`
 | 
				
			||||||
	Genres             []string       `json:"genres"`
 | 
						Genres            []string       `json:"genres"`
 | 
				
			||||||
	Identifiers        []Identifier   `json:"identifiers"`
 | 
						Identifiers       []Identifier   `json:"identifiers"`
 | 
				
			||||||
	Images             []Image        `json:"images"`
 | 
						Images            []Image        `json:"images"`
 | 
				
			||||||
	Labels             []LabelSource  `json:"labels"`
 | 
						Labels            []LabelSource  `json:"labels"`
 | 
				
			||||||
	Master_id          int            `json:"master_id"`
 | 
						LowestPrice       float64        `json:"lowest_price"`
 | 
				
			||||||
	Master_url         string         `json:"master_url"`
 | 
						MasterID          int            `json:"master_id"`
 | 
				
			||||||
	Notes              string         `josn:"notes"`
 | 
						MasterURL         string         `json:"master_url"`
 | 
				
			||||||
	Released           string         `json:"released"`
 | 
						Notes             string         `json:"notes,omitempty"`
 | 
				
			||||||
	Released_formatted string         `json:"released_formatted"`
 | 
						NumForSale        int            `json:"numfor_sale,omitempty"`
 | 
				
			||||||
	Resource_url       string         `json:"resource_url"`
 | 
						Released          string         `json:"released"`
 | 
				
			||||||
	Status             string         `json:"status"`
 | 
						ReleasedFormatted string         `json:"released_formatted"`
 | 
				
			||||||
	Styles             []string       `json:"styles"`
 | 
						ResourceURL       string         `json:"resource_url"`
 | 
				
			||||||
	Tracklist          []Track        `json:"tracklist"`
 | 
						// Series
 | 
				
			||||||
	Uri                string         `json:"uri"`
 | 
						Status    string   `json:"status"`
 | 
				
			||||||
	Videos             []Video        `json:"videos"`
 | 
						Styles    []string `json:"styles"`
 | 
				
			||||||
	Year               int            `json:"year"`
 | 
						Tracklist []Track  `json:"tracklist"`
 | 
				
			||||||
 | 
						URI       string   `json:"uri"`
 | 
				
			||||||
 | 
						Videos    []Video  `json:"videos"`
 | 
				
			||||||
 | 
						Year      int      `json:"year"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func newReleaseService(api *apirequest.API) *ReleaseService {
 | 
					type RequestRelease struct {
 | 
				
			||||||
	return &ReleaseService{
 | 
						Curr_abbr string
 | 
				
			||||||
		api: api.Path("releases/"),
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (self *ReleaseService) Release(params *ReleaseParams) (*Release, *http.Response, error) {
 | 
					// Release returns release by release's ID
 | 
				
			||||||
 | 
					func (c *Client) Release(releaseID int) (*Release, error) {
 | 
				
			||||||
	release := new(Release)
 | 
						release := new(Release)
 | 
				
			||||||
	apiError := new(APIError)
 | 
						apiError := new(APIError)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	resp, err := self.api.New().Get(params.Release_id).Receive(release, apiError)
 | 
						req := &RequestRelease{Curr_abbr: c.currency}
 | 
				
			||||||
	return release, resp, relevantError(err, *apiError)
 | 
						_, err := c.api.New().Get("releases/"+strconv.Itoa(releaseID)).QueryStruct(req).Receive(release, apiError)
 | 
				
			||||||
 | 
						return release, relevantError(err, *apiError)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,7 +9,7 @@ func TestReleaseService_Release(t *testing.T) {
 | 
				
			|||||||
	expectedTitle := "Elephant Riddim"
 | 
						expectedTitle := "Elephant Riddim"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	d := NewClient(testUserAgent, testToken)
 | 
						d := NewClient(testUserAgent, testToken)
 | 
				
			||||||
	release, _, err := d.Release.Release(&ReleaseParams{Release_id: "8138518"})
 | 
						release, err := d.Release.Release(8138518)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	check(t, err)
 | 
						check(t, err)
 | 
				
			||||||
	assert(t, release.Title == expectedTitle, fmt.Sprintf("Release.Title looked for %s, and received %s ", expectedTitle, release.Title))
 | 
						assert(t, release.Title == expectedTitle, fmt.Sprintf("Release.Title looked for %s, and received %s ", expectedTitle, release.Title))
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										28
									
								
								search.go
									
									
									
									
									
								
							
							
						
						
									
										28
									
								
								search.go
									
									
									
									
									
								
							@@ -44,20 +44,20 @@ type Search struct {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// Result describes a part of search result
 | 
					// Result describes a part of search result
 | 
				
			||||||
type Result struct {
 | 
					type Result struct {
 | 
				
			||||||
	Style        []string  `json:"style,omitempty"`
 | 
						Style       []string  `json:"style,omitempty"`
 | 
				
			||||||
	Thumb        string    `json:"thumb,omitempty"`
 | 
						Thumb       string    `json:"thumb,omitempty"`
 | 
				
			||||||
	Title        string    `json:"title,omitempty"`
 | 
						Title       string    `json:"title,omitempty"`
 | 
				
			||||||
	Country      string    `json:"country,omitempty"`
 | 
						Country     string    `json:"country,omitempty"`
 | 
				
			||||||
	Format       []string  `json:"format,omitempty"`
 | 
						Format      []string  `json:"format,omitempty"`
 | 
				
			||||||
	Uri          string    `json:"uri,omitempty"`
 | 
						URI         string    `json:"uri,omitempty"`
 | 
				
			||||||
	Community    Community `json:"community,omitempty"`
 | 
						Community   Community `json:"community,omitempty"`
 | 
				
			||||||
	Label        []string  `json:"label,omitempty"`
 | 
						Label       []string  `json:"label,omitempty"`
 | 
				
			||||||
	Catno        string    `json:"catno,omitempty"`
 | 
						Catno       string    `json:"catno,omitempty"`
 | 
				
			||||||
	Year         string    `json:"year,omitempty"`
 | 
						Year        string    `json:"year,omitempty"`
 | 
				
			||||||
	Genre        []string  `json:"genre,omitempty"`
 | 
						Genre       []string  `json:"genre,omitempty"`
 | 
				
			||||||
	Resource_url string    `json:"resource_url,omitempty"`
 | 
						ResourceURL string    `json:"resource_url,omitempty"`
 | 
				
			||||||
	Type         string    `json:"type,omitempty"`
 | 
						Type        string    `json:"type,omitempty"`
 | 
				
			||||||
	Id           int       `json:"id,omitempty"`
 | 
						ID          int       `json:"id,omitempty"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func newSearchService(api *apirequest.API) *SearchService {
 | 
					func newSearchService(api *apirequest.API) *SearchService {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user