-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeezer.go
More file actions
43 lines (37 loc) · 830 Bytes
/
Copy pathdeezer.go
File metadata and controls
43 lines (37 loc) · 830 Bytes
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
package deezer
import (
"errors"
"net/url"
"strconv"
"github.com/jmcvetta/napping"
)
var BaseUrl = "http://api.deezer.com"
func listParams(index, limit int) *url.Values {
v := &url.Values{}
v.Set("index", strconv.Itoa(index))
v.Set("limit", strconv.Itoa(limit))
return v
}
func get(path string, params *url.Values, result interface{}) error {
url := BaseUrl + path
errMsg := ErrorResponse{}
_, err := napping.Get(url, params, result, &errMsg)
if err != nil {
return err
}
if errMsg.Error.Code != 0 {
return errors.New(errMsg.Error.String())
}
return nil
}
func Get(url string, result interface{}) error {
errMsg := ErrorResponse{}
_, err := napping.Get(url, nil, result, &errMsg)
if err != nil {
return err
}
if errMsg.Error.Code != 0 {
return errors.New(errMsg.Error.String())
}
return nil
}