-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
out.go
82 lines (70 loc) · 1.89 KB
/
out.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 banks
import (
"fmt"
"net/http"
"reflect"
"strings"
"github.com/go-numb/go-exchanges/api/bitflyer/v1/types"
)
const BANKOUTPATH = "/v1/me/getwithdrawals"
type RequestForOut struct {
MessageID string `json:"message_id" url:"message_id"`
Pagination types.Pagination `json:",inline"`
}
type ResponseForOut []Bankout
type Bankout struct {
OrderID string `json:"order_id"`
CurrencyCode string `json:"currency_code"`
Amount float64 `json:"amount"`
Address string `json:"address"`
TxHash string `json:"tx_hash"`
Fee float64 `json:"fee"`
AdditionalFee float64 `json:"additional_fee"`
Status string `json:"status"`
EventDate types.ExchangeTime `json:"event_date"`
ID int `json:"id"`
}
func NewForOut(messageID string) *RequestForOut {
return &RequestForOut{
MessageID: messageID,
}
}
func (p *RequestForOut) SetPagination(count, beforeID, afterID int) *RequestForOut {
if count != 0 {
p.Pagination.Count = count
}
if beforeID != 0 {
p.Pagination.Before = beforeID
}
if afterID != 0 {
p.Pagination.After = afterID
}
return p
}
func (p *RequestForOut) Path() string {
return BANKOUTPATH
}
func (p *RequestForOut) Method() string {
return http.MethodGet
}
func (p *RequestForOut) Query() string {
var q string
if p.MessageID != "" {
q += fmt.Sprintf("&message_id=%s", p.MessageID)
}
if !reflect.DeepEqual(p.Pagination, types.Pagination{}) {
if p.Pagination.Count != 0 {
q += fmt.Sprintf("&count=%d", p.Pagination.Count)
}
if p.Pagination.Before != 0 {
q += fmt.Sprintf("&before=%d", p.Pagination.Before)
}
if p.Pagination.After != 0 {
q += fmt.Sprintf("&after=%d", p.Pagination.After)
}
}
return strings.TrimLeft(q, "&")
}
func (p *RequestForOut) Payload() []byte {
return nil
}