-
Notifications
You must be signed in to change notification settings - Fork 1
/
podcasts.go
50 lines (40 loc) · 1.07 KB
/
podcasts.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package dev
import (
"context"
"fmt"
"github.com/google/go-querystring/query"
)
type PodcastEpisode struct {
TypeOf string `json:"type_of"`
ID int32 `json:"id"`
Path string `json:"path"`
ImageURL string `json:"image_url"`
Title string `json:"title"`
Podcast struct {
Title string `json:"title"`
Slug string `json:"slug"`
ImageURL string `json:"image_url"`
}
}
type PodcastQueryParams struct {
Page int32 `url:"page"`
PerPage int32 `url:"per_page"`
Username string `url:"username"`
}
// GetPublishedPodcastEpisodes allows the client to retrieve a list of podcast episodes
func (c *Client) GetPublishedPodcastEpisodes(q PodcastQueryParams) ([]PodcastEpisode, error) {
var podcasts []PodcastEpisode
query, err := query.Values(q)
if err != nil {
return nil, err
}
path := fmt.Sprintf("/podcast_episodes?%s", query.Encode())
req, err := c.NewRequest(context.Background(), "GET", path, nil)
if err != nil {
return nil, err
}
if err := c.SendHttpRequest(req, &podcasts); err != nil {
return nil, err
}
return podcasts, nil
}