-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
executions.go
85 lines (72 loc) · 2.2 KB
/
executions.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
package list
import (
"fmt"
"net/http"
"reflect"
"github.com/go-numb/go-exchanges/api/bitflyer/v1/types"
)
const EXECUTIONSPATH = "/v1/me/getexecutions"
type RequestForExecutions struct {
ProductCode types.ProductCode `json:"product_code" url:"product_code"`
Pagination types.Pagination `json:",inline"`
ChildOrderID string `json:"child_order_id,omitempty"`
ChildOrderAcceptanceID string `json:"child_order_acceptance_id,omitempty"`
}
type ResponseForExecutions []Executions
type Executions struct {
ChildOrderID string `json:"child_order_id"`
ChildOrderAcceptanceID string `json:"child_order_acceptance_id"`
Side string `json:"side"`
Price float64 `json:"price"`
Size float64 `json:"size"`
Commission float64 `json:"commission"`
ExecDate types.ExchangeTime `json:"exec_date"`
ID int `json:"id"`
}
func NewForExecutions(
code types.ProductCode,
id, acceptanceID string,
count,
after,
before int) *RequestForExecutions {
return &RequestForExecutions{
ProductCode: code,
ChildOrderID: id,
ChildOrderAcceptanceID: acceptanceID,
Pagination: types.Pagination{
Count: count,
After: after,
Before: before,
},
}
}
func (p *RequestForExecutions) Path() string {
return EXECUTIONSPATH
}
func (p *RequestForExecutions) Method() string {
return http.MethodGet
}
func (p *RequestForExecutions) Query() string {
q := "product_code=" + string(p.ProductCode)
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)
}
}
if p.ChildOrderID != "" {
q += fmt.Sprintf("&child_order_id=%s", p.ChildOrderID)
}
if p.ChildOrderAcceptanceID != "" {
q += fmt.Sprintf("&child_order_acceptance_id=%s", p.ChildOrderAcceptanceID)
}
return q
}
func (p *RequestForExecutions) Payload() []byte {
return nil
}