-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.go
executable file
·82 lines (66 loc) · 1.41 KB
/
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package client
type Client struct {
http *HttpClient
}
var c *Client
func New() *Client {
httpClient := newHttpClient()
c = &Client{
http: httpClient,
}
return c
}
func getClient() *Client {
return c
}
func (c *Client) Auth(username, password string) (string, bool) {
data := make(map[string]interface{})
data["username"] = username
data["password"] = password
json, err := c.http.request("POST", "/v1/login", data)
if err != nil {
return "", false
}
t, err := json.Get("Document").String()
if t == "" || err != nil {
return "", false
}
c.http.Token = t
return t, true
}
func (c *Client) TopGainers() *Resource {
r := NewResource("TopGainers", "/v1/gainers")
return r
}
func (c *Client) TopLosers() *Resource {
r := NewResource("TopLosers", "/v1/losers")
return r
}
func (c *Client) Derivatives() *Resource {
r := NewResource("Derivatives", "/v1/derivatives")
return r
}
func (c *Client) Dex() *Resource {
r := NewResource("Dex", "/v1/dex")
return r
}
func (c *Client) Lending() *Resource {
r := NewResource("Lending", "/v1/lending")
return r
}
func (c *Client) Spot() *Resource {
r := NewResource("Spot", "/v1/spot")
return r
}
func (c *Client) News() *Resource {
r := NewResource("News", "/v1/news")
return r
}
func (c *Client) History(year int) *HistoryResource {
r := NewHistoryResource(year)
return r
}
func (c *Client) LivePrice() *PriceResource {
r := NewPriceResource()
return r
}