forked from pinealctx/quoter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodel.go
57 lines (50 loc) · 1.15 KB
/
model.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
package quoter
type SubscribeRequest struct {
Method string `json:"method"`
ID string `json:"id"`
Data struct {
CryptoIDs []int `json:"cryptoIds"`
} `json:"data"`
}
func NewSubscribeRequest(cryptoIDs []int) *SubscribeRequest {
return &SubscribeRequest{
Method: "subscribe",
ID: "price",
Data: struct {
CryptoIDs []int `json:"cryptoIds"`
}{
CryptoIDs: cryptoIDs,
},
}
}
type SubscribeResponse struct {
ID string `json:"id"`
Data struct {
Timestamp int64 `json:"t"`
CR struct {
ID int `json:"id"`
Price float64 `json:"p"`
} `json:"cr"`
} `json:"d"`
S string `json:"s"`
}
type LatestResponse struct {
Data []*LatestData `json:"data"`
Status *Status `json:"status"`
}
type Status struct {
Timestamp string `json:"timestamp"`
ErrorCode int `json:"error_code,string"`
ErrorMessage string `json:"error_message"`
}
type LatestData struct {
ID int `json:"id"`
Name string `json:"name"`
Symbol string `json:"symbol"`
Slug string `json:"slug"`
Quotes []*Quote `json:"quotes"`
}
type Quote struct {
Name int `json:"name,string"`
Price float64 `json:"price"`
}