From e3a28f1eab6024b11560423548cabe7415e24e74 Mon Sep 17 00:00:00 2001 From: Kirill Sysoev Date: Wed, 20 Mar 2024 08:03:24 +0000 Subject: [PATCH] Updates API schema --- calls.go | 8 ++++ schema/authorize_resp.go | 3 ++ schema/p2p_country_list.go | 75 +++++++++++++++++++++++++++++++ schema/p2p_country_list_resp.go | 78 +++++++++++++++++++++++++++++++++ 4 files changed, 164 insertions(+) create mode 100644 schema/p2p_country_list.go create mode 100644 schema/p2p_country_list_resp.go diff --git a/calls.go b/calls.go index 227ee7d..294a4a8 100644 --- a/calls.go +++ b/calls.go @@ -540,6 +540,14 @@ func (a *DerivAPI) P2PChatCreate(r schema.P2PChatCreate) (resp schema.P2PChatCre return } +// P2PCountryList List all or specific country and its payment methods. +func (a *DerivAPI) P2PCountryList(r schema.P2PCountryList) (resp schema.P2PCountryListResp, err error) { + id := a.getNextRequestID() + r.ReqId = &id + err = a.SendRequest(id, r, &resp) + return +} + // P2POrderCancel Cancel a P2P order. func (a *DerivAPI) P2POrderCancel(r schema.P2POrderCancel) (resp schema.P2POrderCancelResp, err error) { id := a.getNextRequestID() diff --git a/schema/authorize_resp.go b/schema/authorize_resp.go index e132e59..720606a 100644 --- a/schema/authorize_resp.go +++ b/schema/authorize_resp.go @@ -91,6 +91,9 @@ type AuthorizeRespAuthorizeAccountListElem struct { // Currency of specified account. Currency *string `json:"currency,omitempty"` + // Currency type for the corresponding currency. + CurrencyType *string `json:"currency_type,omitempty"` + // Epoch of date till client has excluded him/herself from the website, only // present if client is self excluded. ExcludedUntil *int `json:"excluded_until,omitempty"` diff --git a/schema/p2p_country_list.go b/schema/p2p_country_list.go new file mode 100644 index 0000000..02d46a8 --- /dev/null +++ b/schema/p2p_country_list.go @@ -0,0 +1,75 @@ +// Code generated by github.com/atombender/go-jsonschema, DO NOT EDIT. + +package schema + +import "encoding/json" +import "fmt" +import "reflect" + +type P2PCountryListP2PCountryList int + +var enumValues_P2PCountryListP2PCountryList = []interface{}{ + 1, +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *P2PCountryListP2PCountryList) UnmarshalJSON(b []byte) error { + var v int + if err := json.Unmarshal(b, &v); err != nil { + return err + } + var ok bool + for _, expected := range enumValues_P2PCountryListP2PCountryList { + if reflect.DeepEqual(v, expected) { + ok = true + break + } + } + if !ok { + return fmt.Errorf("invalid value (expected one of %#v): %#v", enumValues_P2PCountryListP2PCountryList, v) + } + *j = P2PCountryListP2PCountryList(v) + return nil +} + +// List all or specific country and its payment methods. +type P2PCountryList struct { + // [Optional] 2-letter country code. If not provided all countries are returned. + Country *string `json:"country,omitempty"` + + // [Optional] The login id of the user. If left unspecified, it defaults to the + // initial authorized token's login id. + Loginid *string `json:"loginid,omitempty"` + + // Must be 1 + P2PCountryList P2PCountryListP2PCountryList `json:"p2p_country_list"` + + // [Optional] Used to pass data through the websocket, which may be retrieved via + // the `echo_req` output field. + Passthrough P2PCountryListPassthrough `json:"passthrough,omitempty"` + + // [Optional] Used to map request to response. + ReqId *int `json:"req_id,omitempty"` +} + +// [Optional] Used to pass data through the websocket, which may be retrieved via +// the `echo_req` output field. +type P2PCountryListPassthrough map[string]interface{} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *P2PCountryList) UnmarshalJSON(b []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(b, &raw); err != nil { + return err + } + if v, ok := raw["p2p_country_list"]; !ok || v == nil { + return fmt.Errorf("field p2p_country_list in P2PCountryList: required") + } + type Plain P2PCountryList + var plain Plain + if err := json.Unmarshal(b, &plain); err != nil { + return err + } + *j = P2PCountryList(plain) + return nil +} diff --git a/schema/p2p_country_list_resp.go b/schema/p2p_country_list_resp.go new file mode 100644 index 0000000..c584b4e --- /dev/null +++ b/schema/p2p_country_list_resp.go @@ -0,0 +1,78 @@ +// Code generated by github.com/atombender/go-jsonschema, DO NOT EDIT. + +package schema + +import "encoding/json" +import "fmt" +import "reflect" + +// Echo of the request made. +type P2PCountryListRespEchoReq map[string]interface{} + +type P2PCountryListRespMsgType string + +var enumValues_P2PCountryListRespMsgType = []interface{}{ + "p2p_country_list", +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *P2PCountryListRespMsgType) UnmarshalJSON(b []byte) error { + var v string + if err := json.Unmarshal(b, &v); err != nil { + return err + } + var ok bool + for _, expected := range enumValues_P2PCountryListRespMsgType { + if reflect.DeepEqual(v, expected) { + ok = true + break + } + } + if !ok { + return fmt.Errorf("invalid value (expected one of %#v): %#v", enumValues_P2PCountryListRespMsgType, v) + } + *j = P2PCountryListRespMsgType(v) + return nil +} + +// List all or specific country and its payment methods. +type P2PCountryListResp struct { + // Echo of the request made. + EchoReq P2PCountryListRespEchoReq `json:"echo_req"` + + // Action name of the request made. + MsgType P2PCountryListRespMsgType `json:"msg_type"` + + // Country identified by country code + P2PCountryList P2PCountryListRespP2PCountryList `json:"p2p_country_list,omitempty"` + + // Optional field sent in request to map to response, present only when request + // contains `req_id`. + ReqId *int `json:"req_id,omitempty"` +} + +const P2PCountryListRespMsgTypeP2PCountryList P2PCountryListRespMsgType = "p2p_country_list" + +// Country identified by country code +type P2PCountryListRespP2PCountryList map[string]interface{} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *P2PCountryListResp) UnmarshalJSON(b []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(b, &raw); err != nil { + return err + } + if v, ok := raw["echo_req"]; !ok || v == nil { + return fmt.Errorf("field echo_req in P2PCountryListResp: required") + } + if v, ok := raw["msg_type"]; !ok || v == nil { + return fmt.Errorf("field msg_type in P2PCountryListResp: required") + } + type Plain P2PCountryListResp + var plain Plain + if err := json.Unmarshal(b, &plain); err != nil { + return err + } + *j = P2PCountryListResp(plain) + return nil +}