Some comments edited

This commit is contained in:
irlndts 2017-04-16 23:49:50 +03:00
parent 4e7c6c065a
commit bce16b5ed1
2 changed files with 6 additions and 1 deletions

View File

@ -34,7 +34,7 @@ import "github.com/irlndts/go-discogs"
```go
client := discogs.NewClient("TestDiscogsClient/0.0.1 +example.com", "")
```
Some requests require authentication (as any user). According to [Discogs](https://www.discogs.com/developers/#page:authentication,header:authentication-discogs-auth-flow), to send requests with Discogs Auth, you have two options: sending your credentials in the query string with key and secret parameters or a token parameter. Key-secret doesn't implemented yet, but token is yes.
Some requests require authentification (as any user). According to [Discogs](https://www.discogs.com/developers/#page:authentication,header:authentication-discogs-auth-flow), to send requests with Discogs Auth, you have two options: sending your credentials in the query string with key and secret parameters or a token parameter. Key-secret doesn't implemented yet, but token is yes.
```go
client := discogs.NewClient("TestDiscogsClient/0.0.1 +example.com", "sometoken")
```

View File

@ -6,10 +6,12 @@ import (
"github.com/irlndts/go-apirequest"
)
// SearchService ...
type SearchService struct {
api *apirequest.API
}
// SerachRequest implements search request model
type SearchRequest struct {
Q string // search query (optional)
Type string // one of release, master, artist, label (optional)
@ -34,11 +36,13 @@ type SearchRequest struct {
Per_page int // optional
}
// Search describes search response
type Search struct {
Pagination Page `json:"pagination"`
Results []Result `json:"results"`
}
// Result describes a part of search result
type Result struct {
Style []string `json:"style"`
Thumb string `json:"thumb"`
@ -62,6 +66,7 @@ func newSearchService(api *apirequest.API) *SearchService {
}
}
// Search makes search request to discogs
func (self *SearchService) Search(params *SearchRequest) (*Search, *http.Response, error) {
search := new(Search)
apiError := new(APIError)