package lmaxapi import ( "bytes" "tickserver/api/lmaxapi/request" ) type IRequest interface { Url() string GetRequestData() *bytes.Buffer } type UrlSetter interface { SetUrl(url string) } //============= multi sub ==============// type MultiSubscribe struct { req []IRequest url string } func NewMultiSubscribe() *MultiSubscribe { return &MultiSubscribe{} } func (multi *MultiSubscribe) Add(req IRequest) { multi.req = append(multi.req, req) } func (multi *MultiSubscribe) SetUrl(url string) { multi.url = url } func (multi *MultiSubscribe) Url() string { if multi.url == "" { return "/secure/subscribe" } return multi.url } func (multi *MultiSubscribe) GetRequestData() *bytes.Buffer { buf := bytes.NewBufferString("") buf.WriteString("") for i := 0; i < len(multi.req); i++ { data2 := multi.req[i].GetRequestData().Bytes() data2 = data2[len("") : len(data2)-len("")] buf.Write(data2) } buf.WriteString("") return buf } type OrderActionsRequest struct { req []IRequest url string } func NewOrderActionsRequest() *OrderActionsRequest { actions := &OrderActionsRequest{} return actions } func (this *OrderActionsRequest) Url() string { return "/secure/trade/orderActions" } func (this *OrderActionsRequest) Add(req IRequest) { this.req = append(this.req, req) } func (this *OrderActionsRequest) GetRequestData() *bytes.Buffer { buf := bytes.NewBufferString("") buf.WriteString("") for i := 0; i < len(this.req); i++ { data2 := this.req[i].GetRequestData().Bytes() data2 = data2[len("") : len(data2)-len("")] send := string(data2) switch this.req[i].(type) { case *request.AmendStopsOrderRequest: send = "" + send + "" case *request.CancelOrderRequest: send = "" + send + "" case *request.ClosingOrderRequest: send = "" + send + "" } buf.WriteString(send) } buf.WriteString("") return buf }