forked from okb48/go-bitflyer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
executions.go
executable file
·58 lines (48 loc) · 1.45 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
package executions
import (
"fmt"
"net/http"
"reflect"
"github.com/go-numb/go-bitflyer/v1/time"
"github.com/go-numb/go-bitflyer/v1/types"
)
type Request struct {
ProductCode types.ProductCode `json:"product_code" url:"product_code"`
Pagination types.Pagination `json:",inline"`
}
type Response []Execution
type Execution struct {
ID int `json:"id"`
ChildOrderID string `json:"child_order_id"`
Side string `json:"side"`
Price float64 `json:"price"`
Size float64 `json:"size"`
Commission float64 `json:"commission"`
ExecDate time.BitflyerTime `json:"exec_date"`
ChildOrderAcceptanceID string `json:"child_order_acceptance_id"`
}
const (
APIPath string = "/v1/me/getexecutions"
)
func (req *Request) Method() string {
return http.MethodGet
}
func (req *Request) Query() string {
// values, _ := query.Values(req)
q := "product_code=" + string(req.ProductCode)
if !reflect.DeepEqual(req.Pagination, types.Pagination{}) {
if req.Pagination.Count != 0 {
q += fmt.Sprintf("&count=%d", req.Pagination.Count)
}
if req.Pagination.Before != 0 {
q += fmt.Sprintf("&before=%d", req.Pagination.Before)
}
if req.Pagination.After != 0 {
q += fmt.Sprintf("&after=%d", req.Pagination.After)
}
}
return q
}
func (req *Request) Payload() []byte {
return nil
}