-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.go
49 lines (42 loc) · 845 Bytes
/
client.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
package main
import (
"net/http"
"os"
"time"
)
var client *MonzoClient
type MonzoClient struct {
id string
secret string
accessToken string
refreshToken string
callbackCode string
code string
httpClient *http.Client
}
func init() {
if client != nil {
return
}
client = &MonzoClient{
id: os.Getenv("MONZO_CLIENT_ID"),
secret: os.Getenv("MONZO_CLIENT_SECRET"),
accessToken: os.Getenv("MONZO_ACCESS_TOKEN"),
refreshToken: os.Getenv("MONZO_REFRESH_TOKEN"),
callbackCode: "",
code: "",
httpClient: &http.Client{
Timeout: time.Second * 10,
},
}
}
func NewClient() *MonzoClient {
return client
}
func (c *MonzoClient) Do(req *http.Request) (*http.Response, error) {
rsp, err := c.httpClient.Do(req)
if err != nil {
return nil, err
}
return rsp, nil
}