-
Notifications
You must be signed in to change notification settings - Fork 19
/
catalog_apple_curators.go
50 lines (41 loc) · 1.39 KB
/
catalog_apple_curators.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 applemusic
import (
"context"
"fmt"
)
// AppleCurators represents a list of apple curators.
type AppleCurators struct {
Data []Curator `json:"data"`
Href string `json:"href,omitempty"`
Next string `json:"next,omitempty"`
}
func (s *CatalogService) getAppleCurators(ctx context.Context, u string) (*AppleCurators, *Response, error) {
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return nil, nil, err
}
appleCurators := &AppleCurators{}
resp, err := s.client.Do(ctx, req, appleCurators)
if err != nil {
return nil, resp, err
}
return appleCurators, resp, nil
}
// GetAppleCurator fetches an apple curator using its identifier.
func (s *CatalogService) GetAppleCurator(ctx context.Context, storefront, id string, opt *Options) (*AppleCurators, *Response, error) {
u := fmt.Sprintf("v1/catalog/%s/apple-curators/%s", storefront, id)
u, err := addOptions(u, opt)
if err != nil {
return nil, nil, err
}
return s.getAppleCurators(ctx, u)
}
// GetAppleCuratorsByIds fetches one or more apple curators using their identifiers.
func (s *CatalogService) GetAppleCuratorsByIds(ctx context.Context, storefront string, ids []string, opt *Options) (*AppleCurators, *Response, error) {
u := fmt.Sprintf("v1/catalog/%s/apple-curators", storefront)
u, err := addOptions(u, makeIdsOptions(ids, opt))
if err != nil {
return nil, nil, err
}
return s.getAppleCurators(ctx, u)
}