github.com/bitfinexcom/bitfinex-api-go@v0.0.0-20210608095005-9e0b26f200fb/pkg/models/fundingcredit/cancel.go (about) 1 package fundingcredit 2 3 import ( 4 "encoding/json" 5 "fmt" 6 ) 7 8 type CancelRequest struct { 9 ID int64 10 } 11 12 func (cr *CancelRequest) ToJSON() ([]byte, error) { 13 resp := struct { 14 ID int64 `json:"id"` 15 }{ 16 ID: cr.ID, 17 } 18 return json.Marshal(resp) 19 } 20 21 // MarshalJSON converts the funding credit cancel request into the format required by the 22 // bitfinex websocket service. 23 func (cr *CancelRequest) MarshalJSON() ([]byte, error) { 24 b, err := cr.ToJSON() 25 if err != nil { 26 return nil, err 27 } 28 return []byte(fmt.Sprintf("[0, \"fcc\", null, %s]", string(b))), nil 29 }