-
Notifications
You must be signed in to change notification settings - Fork 0
/
profiles.go
47 lines (37 loc) · 959 Bytes
/
profiles.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
package arvanvod
import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)
// Get all channel's profiles
func (c *Client) GetChannelProfiles(ctx context.Context, channel, filter string, page, perPage int) (*GetChannelProfilesModel, error) {
requestURL := fmt.Sprintf("%s/channels/%s/profiles?filter=%s&page=%d&per_page=%d", c.options.BaseUrl,channel, filter, page, perPage)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, requestURL, nil)
if err != nil {
return nil, err
}
res, err := http.DefaultClient.Do(req)
if err != nil {
return nil, err
}
err = getErrorByStatus(res.StatusCode)
if err != nil {
return nil, err
}
defer res.Body.Close()
resBody, err := ioutil.ReadAll(res.Body)
if err != nil {
return nil, err
}
response := new(GetChannelProfilesModel)
err = json.Unmarshal(resBody, response)
if err != nil {
return nil, err
}
return response, nil
}
type GetChannelProfilesModel struct {
}