Test ListenBrainz client

This commit is contained in:
Philipp Wolfer 2023-11-11 22:40:43 +01:00
parent cf8a6d2ab6
commit 3ac3fac317
No known key found for this signature in database
GPG key ID: 8FDF744D4919943B
5 changed files with 153 additions and 3 deletions

View file

@ -34,7 +34,7 @@ const DefaultItemsPerGet = 25
const MaxItemsPerGet = 1000
type Client struct {
resty *resty.Client
HttpClient *resty.Client
MaxResults int
}
@ -45,7 +45,7 @@ func New(token string) Client {
resty.SetAuthToken(token)
resty.SetHeader("Accept", "application/json")
client := Client{
resty: resty,
HttpClient: resty,
MaxResults: DefaultItemsPerGet,
}
@ -55,7 +55,7 @@ func New(token string) Client {
func (c Client) GetListens(user string, maxTime time.Time, minTime time.Time) (GetListensResult, error) {
const path = "/user/{username}/listens"
result := &GetListensResult{}
_, err := c.resty.R().
_, err := c.HttpClient.R().
SetPathParam("username", user).
SetQueryParams(map[string]string{
"max_ts": strconv.FormatInt(maxTime.Unix(), 10),