-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeneral-api.go
154 lines (113 loc) · 2.82 KB
/
general-api.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
package wazirx_client
import (
"context"
"encoding/json"
"fmt"
"net/http"
api "github.com/yuvan11/wazirx-go/wazirx-client/endpoints"
)
// PING SERVICE
type PingService struct {
C *Client
}
func (s *PingService) FetchPingStatus(ctx context.Context) (res string) {
r := &Request{
Method: http.MethodGet,
Endpoint: api.PING,
SecType: SecTypeNone,
}
data, err := s.C.HandleAPI(ctx, r)
if err != nil {
fmt.Println("Error in Handling API")
}
res = string(data)
return res
}
// SERVER TIME
type ServerTimeService struct {
C *Client
}
type ServerTime struct {
ServerTime int64 `json:"serverTime"`
}
// SYSTEM STATUS
type SystemStatusService struct {
C *Client
}
type SystemStatus struct {
Status string `json:"status"`
Message string `json:"message"`
}
func (s *SystemStatusService) FetchSystemStatus(ctx context.Context) *SystemStatus {
r := &Request{
Method: http.MethodGet,
Endpoint: api.SYSTEM_STATUS,
SecType: SecTypeNone,
}
data, err := s.C.HandleAPI(ctx, r)
if err != nil {
fmt.Println(err)
}
result := new(SystemStatus)
if err := json.Unmarshal(data, &result); err != nil {
fmt.Println("Can not unmarshal JSON")
}
return result
}
func (s *ServerTimeService) FetchServerTime(ctx context.Context) *ServerTime {
r := &Request{
Method: http.MethodGet,
Endpoint: api.TIME,
SecType: SecTypeNone,
}
data, err := s.C.HandleAPI(ctx, r)
if err != nil {
fmt.Println(err)
}
result := new(ServerTime)
if err := json.Unmarshal(data, &result); err != nil {
fmt.Println("Can not unmarshal JSON")
}
return result
}
// EXCHANGE INFORMATION
type Filters struct {
FilterType string `json:"filterType"`
MinPrice string `json:"minPrice"`
TickSize string `json:"tickSize"`
}
type Symbols struct {
Symbol string `json:"symbol"`
Status string `json:"status"`
BaseAsset string `json:"baseAsset"`
QuoteAsset string `json:"quoteAsset"`
BaseAssetPrecision int32 `json:"baseAssetPrecision"`
QuoteAssetPrecision int32 `json:"quoteAssetPrecision"`
OrderTypes []string `json:"orderTypes"`
IsSpotTradingAllowed bool `json:"isSpotTradingAllowed"`
Filters []Filters `json:"filters"`
}
type ExchangeInfo struct {
TimeZone string `json:"timezone"`
ServerTIme int64 `json:"serverTime"`
Symbols []Symbols `json:"symbols"`
}
type ExchangeInfoService struct {
C *Client
}
func (s *ExchangeInfoService) FetchExchangeInfo(ctx context.Context) *ExchangeInfo {
r := &Request{
Method: http.MethodGet,
Endpoint: api.EXCHAGE_INFO,
SecType: SecTypeNone,
}
data, err := s.C.HandleAPI(ctx, r)
if err != nil {
fmt.Println(err)
}
result := new(ExchangeInfo)
if err := json.Unmarshal(data, &result); err != nil {
fmt.Println("Can not unmarshal JSON", err)
}
return result
}