mirror of
https://git.sr.ht/~phw/scotty
synced 2025-05-03 23:17:05 +02:00
Spotify: Implemented API request and tests for user tracks
This commit is contained in:
parent
d0739aad0f
commit
ed9debc127
4 changed files with 623 additions and 9 deletions
|
@ -68,13 +68,27 @@ func (c Client) recentlyPlayed(after *time.Time, before *time.Time, limit int) (
|
|||
request.SetQueryParam("after", strconv.FormatInt(after.Unix(), 10))
|
||||
} else if before != nil {
|
||||
request.SetQueryParam("before", strconv.FormatInt(before.Unix(), 10))
|
||||
|
||||
}
|
||||
response, err := request.Get(path)
|
||||
|
||||
if response.StatusCode() != 200 {
|
||||
err = errors.New(response.String())
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (c Client) UserTracks(offset int, limit int) (result TracksResult, err error) {
|
||||
const path = "/me/tracks"
|
||||
response, err := c.HttpClient.R().
|
||||
SetQueryParams(map[string]string{
|
||||
"offset": strconv.Itoa(offset),
|
||||
"limit": strconv.Itoa(limit),
|
||||
}).
|
||||
SetResult(&result).
|
||||
Get(path)
|
||||
|
||||
if response.StatusCode() != 200 {
|
||||
err = errors.New(response.String())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue