forked from ccxt/go-binance
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver_service.go
50 lines (45 loc) · 967 Bytes
/
server_service.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
package eoptions
import (
"context"
"encoding/json"
"net/http"
)
// PingService ping server
type PingService struct {
c *Client
}
// Do send request
func (s *PingService) Do(ctx context.Context, opts ...RequestOption) (err error) {
r := &request{
method: http.MethodGet,
endpoint: "/eapi/v1/ping",
}
data, _, err := s.c.callAPI(ctx, r, opts...)
if err != nil {
return err
}
d := map[string]string{}
err = json.Unmarshal(data, &d)
return err
}
// ServerTimeService get server time
type ServerTimeService struct {
c *Client
}
// Do send request
func (s *ServerTimeService) Do(ctx context.Context, opts ...RequestOption) (serverTime int64, err error) {
r := &request{
method: http.MethodGet,
endpoint: "/eapi/v1/time",
}
data, _, err := s.c.callAPI(ctx, r, opts...)
if err != nil {
return 0, err
}
j, err := newJSON(data)
if err != nil {
return 0, err
}
serverTime = j.Get("serverTime").MustInt64()
return serverTime, nil
}