-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlist.go
64 lines (50 loc) · 1.28 KB
/
list.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package soumuradio
import (
"context"
"github.com/tomato3713/soumuradio/internal"
)
// getListAPI is Method for getting number
func (c *Client) getListAPI(ctx context.Context, opt ListOpts) (*internal.Lists, error) {
spath := "/musen/list"
req, err := c.newRequest(ctx, "GET", spath, opt, nil)
if err != nil {
logf("try URL: %v", req.URL)
return nil, err
}
res, err := c.HTTPClient.Do(req)
if err != nil {
return nil, err
}
if err = checkStatusCode(res); err != nil {
return nil, err
}
var lists internal.Lists
if err := decodeBody(res, &lists, nil); err != nil {
return nil, err
}
return &lists, nil
}
func (c *Client) GetRadioLicenseList(ctx context.Context, opt ListOpts) (LicenseList, error) {
opt.ST = License
result, err := c.getListAPI(ctx, opt)
if err != nil {
return LicenseList{}, err
}
ret, err := convertInternalLists2LicenseList(result)
if err != nil {
return LicenseList{}, err
}
return ret, nil
}
func (c *Client) GetRadioRegistrationList(ctx context.Context, opt ListOpts) (RegistrationList, error) {
opt.ST = Registration
result, err := c.getListAPI(ctx, opt)
if err != nil {
return RegistrationList{}, err
}
ret, err := convertInternalLists2RegistrationList(result)
if err != nil {
return RegistrationList{}, err
}
return ret, nil
}