Skip to content

Commit 7737c23

Browse files
committed
Fix BatchFetchEpisodes and BatchFetchPodcasts function signature bugs.
1 parent a3b1d10 commit 7737c23

File tree

3 files changed

+52
-14
lines changed

3 files changed

+52
-14
lines changed

client.go

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"fmt"
77
"net/http"
88
"net/url"
9-
"strings"
109
)
1110

1211
// HTTPClient is the client interface
@@ -19,8 +18,8 @@ type HTTPClient interface {
1918
FetchBestPodcasts(args map[string]string) (*Response, error)
2019
FetchPodcastByID(id string, args map[string]string) (*Response, error)
2120
FetchEpisodeByID(id string, args map[string]string) (*Response, error)
22-
BatchFetchEpisodes(ids []string, args map[string]string) (*Response, error)
23-
BatchFetchPodcasts(ids []string, args map[string]string) (*Response, error)
21+
BatchFetchEpisodes(args map[string]string) (*Response, error)
22+
BatchFetchPodcasts(args map[string]string) (*Response, error)
2423
FetchCuratedPodcastsListByID(id string, args map[string]string) (*Response, error)
2524
FetchPodcastGenres(args map[string]string) (*Response, error)
2625
FetchPodcastRegions(args map[string]string) (*Response, error)
@@ -98,16 +97,20 @@ func (c *standardHTTPClient) FetchEpisodeByID(id string, args map[string]string)
9897
return c.get(fmt.Sprintf("episodes/%s", id), args)
9998
}
10099

101-
func (c *standardHTTPClient) BatchFetchEpisodes(ids []string, args map[string]string) (*Response, error) {
102-
return c.post("episodes", args, url.Values{
103-
"ids": []string{strings.Join(ids, ",")},
104-
})
100+
func (c *standardHTTPClient) BatchFetchEpisodes(args map[string]string) (*Response, error) {
101+
values := url.Values{}
102+
for k, v := range args {
103+
values.Set(k, v)
104+
}
105+
return c.post("episodes", args, values)
105106
}
106107

107-
func (c *standardHTTPClient) BatchFetchPodcasts(ids []string, args map[string]string) (*Response, error) {
108-
return c.post("podcasts", args, url.Values{
109-
"ids": []string{strings.Join(ids, ",")},
110-
})
108+
func (c *standardHTTPClient) BatchFetchPodcasts(args map[string]string) (*Response, error) {
109+
values := url.Values{}
110+
for k, v := range args {
111+
values.Set(k, v)
112+
}
113+
return c.post("podcasts", args, values)
111114
}
112115

113116
func (c *standardHTTPClient) FetchCuratedPodcastsListByID(id string, args map[string]string) (*Response, error) {

go.sum

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
2+
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
3+
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
4+
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
5+
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 h1:VLliZ0d+/avPrXXH+OakdXhpJuEoBZuwh1m2j7U6Iug=
6+
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
7+
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
8+
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
9+
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
10+
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
11+
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
12+
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
13+
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
14+
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
15+
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
16+
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
17+
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
18+
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
19+
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
20+
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
21+
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
22+
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
23+
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
24+
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
25+
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
26+
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
27+
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
28+
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
29+
golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU=
30+
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
31+
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
32+
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

integration_expectations_test.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,11 @@ func TestSearchIntegration(t *testing.T) {
134134
{
135135
Method: "POST",
136136
Path: "episodes",
137-
Args: map[string]string{},
137+
Args: map[string]string{
138+
"ids": "123,456",
139+
},
138140
ExecuteFunc: func(args map[string]string) (*listennotes.Response, error) {
139-
return client.BatchFetchEpisodes([]string{"123", "456"}, args)
141+
return client.BatchFetchEpisodes(args)
140142
},
141143
ValidateFunc: func(resp *listennotes.Response, respErr error) error {
142144
expectNoError(respErr)
@@ -148,10 +150,11 @@ func TestSearchIntegration(t *testing.T) {
148150
Method: "POST",
149151
Path: "podcasts",
150152
Args: map[string]string{
153+
"id": "123,456",
151154
"show_latest_episodes": "1",
152155
},
153156
ExecuteFunc: func(args map[string]string) (*listennotes.Response, error) {
154-
return client.BatchFetchPodcasts([]string{"123", "456"}, args)
157+
return client.BatchFetchPodcasts(args)
155158
},
156159
ValidateFunc: func(resp *listennotes.Response, respErr error) error {
157160
expectNoError(respErr)

0 commit comments

Comments
 (0)