6 Commits
v0.2 ... v0.2.2

Author SHA1 Message Date
Artem Piskun
d987189090 DSCGS-33 Added MasterID to Search.Result (#34) 2019-11-05 13:40:34 +03:00
Artem Piskun
77c264c993 DSCGS-31 Search fix (#32) 2019-10-29 13:34:43 +03:00
Abe Massry
84a3ecd4c5 add cover_image to search results (#30) 2019-09-02 18:15:44 +03:00
Abe Massry
f9bfcf8fba Update search example for current code behavior (#29) 2019-08-28 12:53:11 +03:00
irlndts
664896b3dd Golangci-lint fix 2019-06-18 15:08:55 +03:00
Artem Piskun
3c48a3e6d4 Merge pull request #28 from irlndts/RemoveVendor 2019-06-06 15:24:00 +03:00
3 changed files with 64 additions and 21 deletions

View File

@@ -79,7 +79,7 @@ type SearchRequest struct {
Example
```go
request := discogs.SearchRequest{Artist: "reggaenauts", ReleaseTitle: "river rock", Page: 0, PerPage: 1}
search, _ := client.Search(request)
search, _ := client.Search.Search(request)
for _, r := range search.Results {
fmt.Println(r.Title)

View File

@@ -50,7 +50,8 @@ func TestNewClient(t *testing.T) {
}, ErrCurrencyNotSupported},
}
for name, tt := range tests {
for name := range tests {
tt := tests[name]
t.Run(name, func(t *testing.T) {
if _, err := NewClient(tt.options); err != tt.err {
t.Errorf("err got=%s; want=%s", err, tt.err)

View File

@@ -47,26 +47,66 @@ func (r *SearchRequest) params() url.Values {
}
params := url.Values{}
params.Set("q", r.Q)
params.Set("type", r.Type)
params.Set("title", r.Title)
params.Set("release_title", r.ReleaseTitle)
params.Set("credit", r.Credit)
params.Set("artist", r.Artist)
params.Set("anv", r.Anv)
params.Set("label", r.Label)
params.Set("genre", r.Genre)
params.Set("style", r.Style)
params.Set("country", r.Country)
params.Set("year", r.Year)
params.Set("format", r.Format)
params.Set("catno", r.Catno)
params.Set("barcode", r.Barcode)
params.Set("track", r.Track)
params.Set("submitter", r.Submitter)
params.Set("contributor", r.Contributor)
if r.Q != "" {
params.Set("q", r.Q)
}
if r.Type != "" {
params.Set("type", r.Type)
}
if r.Title != "" {
params.Set("title", r.Title)
}
if r.ReleaseTitle != "" {
params.Set("release_title", r.ReleaseTitle)
}
if r.Credit != "" {
params.Set("credit", r.Credit)
}
if r.Artist != "" {
params.Set("artist", r.Artist)
}
if r.Anv != "" {
params.Set("anv", r.Anv)
}
if r.Label != "" {
params.Set("label", r.Label)
}
if r.Genre != "" {
params.Set("genre", r.Genre)
}
if r.Style != "" {
params.Set("style", r.Style)
}
if r.Country != "" {
params.Set("country", r.Country)
}
if r.Year != "" {
params.Set("year", r.Year)
}
if r.Format != "" {
params.Set("format", r.Format)
}
if r.Catno != "" {
params.Set("catno", r.Catno)
}
if r.Barcode != "" {
params.Set("barcode", r.Barcode)
}
if r.Track != "" {
params.Set("track", r.Track)
}
if r.Submitter != "" {
params.Set("submitter", r.Submitter)
}
if r.Contributor != "" {
params.Set("contributor", r.Contributor)
}
params.Set("page", strconv.Itoa(r.Page))
params.Set("per_page", strconv.Itoa(r.PerPage))
if r.PerPage != 0 {
params.Set("per_page", strconv.Itoa(r.PerPage))
}
return params
}
@@ -80,6 +120,7 @@ type Search struct {
type Result struct {
Style []string `json:"style,omitempty"`
Thumb string `json:"thumb,omitempty"`
CoverImage string `json:"cover_image,omitempty"`
Title string `json:"title,omitempty"`
Country string `json:"country,omitempty"`
Format []string `json:"format,omitempty"`
@@ -92,6 +133,7 @@ type Result struct {
ResourceURL string `json:"resource_url,omitempty"`
Type string `json:"type,omitempty"`
ID int `json:"id,omitempty"`
MasterID int `json:"master_id,omitempty"`
}
// Search makes search request to discogs.