-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlingotek.go
48 lines (37 loc) · 1022 Bytes
/
lingotek.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
package lingotek
import (
"errors"
"net/http"
"net/url"
)
var ServerError = errors.New("Server returned an error")
var EndOfList = errors.New("No next rel found")
var IdRequired = errors.New("No ID given")
const target = "https://sandbox-api.lingotek.com/api/"
type Lingotek struct {
AccessToken string
client *http.Client
}
func NewApi(accessToken string, client *http.Client) *Lingotek {
api := Lingotek{"bearer " + accessToken, client}
return &api
}
func (l *Lingotek) createDummyResponse(path string, params *url.Values) *Response {
initialResponse := Response{}
if params == nil {
params = &url.Values{}
}
params.Set("limit", "10")
params.Set("offset", "0")
selfLink := Link{
Rel: []string{"self"},
Href: path + "?" + params.Encode(),
}
nextLink := Link{
Rel: []string{"next"},
Href: path + "?" + params.Encode(),
}
initialResponse.Links = append(initialResponse.Links, selfLink)
initialResponse.Links = append(initialResponse.Links, nextLink)
return &initialResponse
}