From 15f538b57799b001a547ae22f8627cd2942b8c16 Mon Sep 17 00:00:00 2001 From: Kirill Sysoev Date: Mon, 9 Oct 2023 08:04:05 +0000 Subject: [PATCH] Updates API schema --- calls.go | 8 + schema/forget_all.go | 2 + schema/p2p_settings.go | 98 +++++++ schema/p2p_settings_resp.go | 525 ++++++++++++++++++++++++++++++++++++ subscription_calls.go | 11 + 5 files changed, 644 insertions(+) create mode 100644 schema/p2p_settings.go create mode 100644 schema/p2p_settings_resp.go diff --git a/calls.go b/calls.go index d33568f..7e2617a 100644 --- a/calls.go +++ b/calls.go @@ -588,6 +588,14 @@ func (a *DerivAPI) P2PPing(r schema.P2PPing) (resp schema.P2PPingResp, err error return } +// P2PSettings Request P2P Settings information. +func (a *DerivAPI) P2PSettings(r schema.P2PSettings) (resp schema.P2PSettingsResp, err error) { + id := a.getNextRequestID() + r.ReqId = &id + err = a.SendRequest(id, r, &resp) + return +} + // PaymentMethods Will return a list payment methods available for the given country. If the request is authenticated the client's residence country will be used. func (a *DerivAPI) PaymentMethods(r schema.PaymentMethods) (resp schema.PaymentMethodsResp, err error) { id := a.getNextRequestID() diff --git a/schema/forget_all.go b/schema/forget_all.go index 47bb753..4fb12a3 100644 --- a/schema/forget_all.go +++ b/schema/forget_all.go @@ -32,6 +32,7 @@ const StreamTypesCashierPayments StreamTypes = "cashier_payments" const StreamTypesP2PAdvert StreamTypes = "p2p_advert" const StreamTypesP2PAdvertiser StreamTypes = "p2p_advertiser" const StreamTypesP2POrder StreamTypes = "p2p_order" +const StreamTypesP2PSettings StreamTypes = "p2p_settings" const StreamTypesProposal StreamTypes = "proposal" const StreamTypesProposalOpenContract StreamTypes = "proposal_open_contract" const StreamTypesTicks StreamTypes = "ticks" @@ -72,6 +73,7 @@ var enumValues_StreamTypes = []interface{}{ "transaction", "trading_platform_asset_listing", "website_status", + "p2p_settings", } // UnmarshalJSON implements json.Unmarshaler. diff --git a/schema/p2p_settings.go b/schema/p2p_settings.go new file mode 100644 index 0000000..d0914cc --- /dev/null +++ b/schema/p2p_settings.go @@ -0,0 +1,98 @@ +// Code generated by github.com/atombender/go-jsonschema, DO NOT EDIT. + +package schema + +import "encoding/json" +import "fmt" +import "reflect" + +type P2PSettingsP2PSettings int + +var enumValues_P2PSettingsP2PSettings = []interface{}{ + 1, +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *P2PSettingsP2PSettings) UnmarshalJSON(b []byte) error { + var v int + if err := json.Unmarshal(b, &v); err != nil { + return err + } + var ok bool + for _, expected := range enumValues_P2PSettingsP2PSettings { + if reflect.DeepEqual(v, expected) { + ok = true + break + } + } + if !ok { + return fmt.Errorf("invalid value (expected one of %#v): %#v", enumValues_P2PSettingsP2PSettings, v) + } + *j = P2PSettingsP2PSettings(v) + return nil +} + +// [Optional] Used to pass data through the websocket, which may be retrieved via +// the `echo_req` output field. Maximum size is 3500 bytes. +type P2PSettingsPassthrough map[string]interface{} + +type P2PSettingsSubscribe int + +var enumValues_P2PSettingsSubscribe = []interface{}{ + 1, +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *P2PSettingsSubscribe) UnmarshalJSON(b []byte) error { + var v int + if err := json.Unmarshal(b, &v); err != nil { + return err + } + var ok bool + for _, expected := range enumValues_P2PSettingsSubscribe { + if reflect.DeepEqual(v, expected) { + ok = true + break + } + } + if !ok { + return fmt.Errorf("invalid value (expected one of %#v): %#v", enumValues_P2PSettingsSubscribe, v) + } + *j = P2PSettingsSubscribe(v) + return nil +} + +// Request P2P Settings information. +type P2PSettings struct { + // Must be `1` + P2PSettings P2PSettingsP2PSettings `json:"p2p_settings"` + + // [Optional] Used to pass data through the websocket, which may be retrieved via + // the `echo_req` output field. Maximum size is 3500 bytes. + Passthrough P2PSettingsPassthrough `json:"passthrough,omitempty"` + + // [Optional] Used to map request to response. + ReqId *int `json:"req_id,omitempty"` + + // [Optional] If set to `1`, will send updates whenever there is an update to P2P + // settings. + Subscribe *P2PSettingsSubscribe `json:"subscribe,omitempty"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *P2PSettings) UnmarshalJSON(b []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(b, &raw); err != nil { + return err + } + if v, ok := raw["p2p_settings"]; !ok || v == nil { + return fmt.Errorf("field p2p_settings in P2PSettings: required") + } + type Plain P2PSettings + var plain Plain + if err := json.Unmarshal(b, &plain); err != nil { + return err + } + *j = P2PSettings(plain) + return nil +} diff --git a/schema/p2p_settings_resp.go b/schema/p2p_settings_resp.go new file mode 100644 index 0000000..f046df9 --- /dev/null +++ b/schema/p2p_settings_resp.go @@ -0,0 +1,525 @@ +// Code generated by github.com/atombender/go-jsonschema, DO NOT EDIT. + +package schema + +import "encoding/json" +import "fmt" +import "reflect" + +// Information of the P2P settings. +type P2PSettingsResp struct { + // Echo of the request made. + EchoReq P2PSettingsRespEchoReq `json:"echo_req"` + + // Action name of the request made. + MsgType P2PSettingsRespMsgType `json:"msg_type"` + + // Peer-to-peer payment system settings. + P2PSettings *P2PSettingsRespP2PSettings `json:"p2p_settings,omitempty"` + + // Optional field sent in request to map to response, present only when request + // contains `req_id`. + ReqId *int `json:"req_id,omitempty"` + + // For subscription requests only. + Subscription *P2PSettingsRespSubscription `json:"subscription,omitempty"` +} + +// Echo of the request made. +type P2PSettingsRespEchoReq map[string]interface{} + +type P2PSettingsRespMsgType string + +const P2PSettingsRespMsgTypeP2PSettings P2PSettingsRespMsgType = "p2p_settings" + +// Peer-to-peer payment system settings. +type P2PSettingsRespP2PSettings struct { + // Maximum number of active ads allowed by an advertiser per currency pair and + // advert type (buy or sell). + AdvertsActiveLimit int `json:"adverts_active_limit"` + + // Adverts will be deactivated if no activity occurs within this period, in days. + AdvertsArchivePeriod *int `json:"adverts_archive_period,omitempty"` + + // Block trading settings + BlockTrade P2PSettingsRespP2PSettingsBlockTrade `json:"block_trade"` + + // A buyer will be blocked for this duration after exceeding the cancellation + // limit, in hours. + CancellationBlockDuration int `json:"cancellation_block_duration"` + + // The period within which to count buyer cancellations, in hours. + CancellationCountPeriod int `json:"cancellation_count_period"` + + // A buyer may cancel an order within this period without negative consequences, + // in minutes after order creation. + CancellationGracePeriod int `json:"cancellation_grace_period"` + + // A buyer will be temporarily barred after marking this number of cancellations + // within cancellation_period. + CancellationLimit int `json:"cancellation_limit"` + + // When 0, only exchanges in local currency are allowed for P2P advertiser. + CrossBorderAdsEnabled P2PSettingsRespP2PSettingsCrossBorderAdsEnabled `json:"cross_border_ads_enabled"` + + // When 1, the P2P service is unavailable. + Disabled P2PSettingsRespP2PSettingsDisabled `json:"disabled"` + + // Indicates the availbility of certain backend features. + FeatureLevel int `json:"feature_level"` + + // Availability of fixed rate adverts. + FixedRateAdverts P2PSettingsRespP2PSettingsFixedRateAdverts `json:"fixed_rate_adverts"` + + // Date on which fixed rate adverts will be deactivated. + FixedRateAdvertsEndDate *string `json:"fixed_rate_adverts_end_date,omitempty"` + + // Availability of floating rate adverts. + FloatRateAdverts P2PSettingsRespP2PSettingsFloatRateAdverts `json:"float_rate_adverts"` + + // Maximum rate offset for floating rate adverts. + FloatRateOffsetLimit float64 `json:"float_rate_offset_limit"` + + // Available local currencies for p2p_advert_list request. + LocalCurrencies []P2PSettingsRespP2PSettingsLocalCurrenciesElem `json:"local_currencies"` + + // Maximum amount of an advert, in USD. + MaximumAdvertAmount float64 `json:"maximum_advert_amount"` + + // Maximum amount of an order, in USD. + MaximumOrderAmount float64 `json:"maximum_order_amount"` + + // Maximum number of orders a user may create per day. + OrderDailyLimit int `json:"order_daily_limit"` + + // Time allowed for order payment, in minutes after order creation. + OrderPaymentPeriod int `json:"order_payment_period"` + + // Local P2P exchange rate which should be used instead of those obtained from the + // `exchange_rates` call. + OverrideExchangeRate *string `json:"override_exchange_rate,omitempty"` + + // Indicates if the payment methods feature is enabled. + PaymentMethodsEnabled P2PSettingsRespP2PSettingsPaymentMethodsEnabled `json:"payment_methods_enabled"` + + // Time after successful order completion during which reviews can be created, in + // hours. + ReviewPeriod float64 `json:"review_period"` + + // List of currencies for which P2P is available + SupportedCurrencies []string `json:"supported_currencies"` +} + +// Block trading settings +type P2PSettingsRespP2PSettingsBlockTrade struct { + // When 1, Block trading is unavailable. + Disabled *P2PSettingsRespP2PSettingsBlockTradeDisabled `json:"disabled,omitempty"` + + // Maximum amount of a block trade advert, in USD. + MaximumAdvertAmount *float64 `json:"maximum_advert_amount,omitempty"` +} + +type P2PSettingsRespP2PSettingsBlockTradeDisabled int + +type P2PSettingsRespP2PSettingsCrossBorderAdsEnabled int + +type P2PSettingsRespP2PSettingsDisabled int + +type P2PSettingsRespP2PSettingsFixedRateAdverts string + +const P2PSettingsRespP2PSettingsFixedRateAdvertsDisabled P2PSettingsRespP2PSettingsFixedRateAdverts = "disabled" +const P2PSettingsRespP2PSettingsFixedRateAdvertsEnabled P2PSettingsRespP2PSettingsFixedRateAdverts = "enabled" +const P2PSettingsRespP2PSettingsFixedRateAdvertsListOnly P2PSettingsRespP2PSettingsFixedRateAdverts = "list_only" + +type P2PSettingsRespP2PSettingsFloatRateAdverts string + +const P2PSettingsRespP2PSettingsFloatRateAdvertsDisabled P2PSettingsRespP2PSettingsFloatRateAdverts = "disabled" +const P2PSettingsRespP2PSettingsFloatRateAdvertsEnabled P2PSettingsRespP2PSettingsFloatRateAdverts = "enabled" +const P2PSettingsRespP2PSettingsFloatRateAdvertsListOnly P2PSettingsRespP2PSettingsFloatRateAdverts = "list_only" + +// Local currency details. +type P2PSettingsRespP2PSettingsLocalCurrenciesElem struct { + // Local currency name + DisplayName string `json:"display_name"` + + // Indicates that there are adverts available for this currency. + HasAdverts P2PSettingsRespP2PSettingsLocalCurrenciesElemHasAdverts `json:"has_adverts"` + + // Indicates that this is local currency for the current country. + IsDefault *P2PSettingsRespP2PSettingsLocalCurrenciesElemIsDefault `json:"is_default,omitempty"` + + // Local currency symbol + Symbol string `json:"symbol"` +} + +type P2PSettingsRespP2PSettingsLocalCurrenciesElemHasAdverts int + +type P2PSettingsRespP2PSettingsLocalCurrenciesElemIsDefault int + +// UnmarshalJSON implements json.Unmarshaler. +func (j *P2PSettingsRespP2PSettingsFloatRateAdverts) UnmarshalJSON(b []byte) error { + var v string + if err := json.Unmarshal(b, &v); err != nil { + return err + } + var ok bool + for _, expected := range enumValues_P2PSettingsRespP2PSettingsFloatRateAdverts { + if reflect.DeepEqual(v, expected) { + ok = true + break + } + } + if !ok { + return fmt.Errorf("invalid value (expected one of %#v): %#v", enumValues_P2PSettingsRespP2PSettingsFloatRateAdverts, v) + } + *j = P2PSettingsRespP2PSettingsFloatRateAdverts(v) + return nil +} + +var enumValues_P2PSettingsRespP2PSettingsLocalCurrenciesElemIsDefault = []interface{}{ + 1, +} +var enumValues_P2PSettingsRespP2PSettingsFloatRateAdverts = []interface{}{ + "disabled", + "enabled", + "list_only", +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *P2PSettingsRespP2PSettingsLocalCurrenciesElemIsDefault) UnmarshalJSON(b []byte) error { + var v int + if err := json.Unmarshal(b, &v); err != nil { + return err + } + var ok bool + for _, expected := range enumValues_P2PSettingsRespP2PSettingsLocalCurrenciesElemIsDefault { + if reflect.DeepEqual(v, expected) { + ok = true + break + } + } + if !ok { + return fmt.Errorf("invalid value (expected one of %#v): %#v", enumValues_P2PSettingsRespP2PSettingsLocalCurrenciesElemIsDefault, v) + } + *j = P2PSettingsRespP2PSettingsLocalCurrenciesElemIsDefault(v) + return nil +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *P2PSettingsRespP2PSettingsCrossBorderAdsEnabled) UnmarshalJSON(b []byte) error { + var v int + if err := json.Unmarshal(b, &v); err != nil { + return err + } + var ok bool + for _, expected := range enumValues_P2PSettingsRespP2PSettingsCrossBorderAdsEnabled { + if reflect.DeepEqual(v, expected) { + ok = true + break + } + } + if !ok { + return fmt.Errorf("invalid value (expected one of %#v): %#v", enumValues_P2PSettingsRespP2PSettingsCrossBorderAdsEnabled, v) + } + *j = P2PSettingsRespP2PSettingsCrossBorderAdsEnabled(v) + return nil +} + +var enumValues_P2PSettingsRespP2PSettingsCrossBorderAdsEnabled = []interface{}{ + 0, + 1, +} +var enumValues_P2PSettingsRespP2PSettingsBlockTradeDisabled = []interface{}{ + 0, + 1, +} +var enumValues_P2PSettingsRespP2PSettingsFixedRateAdverts = []interface{}{ + "disabled", + "enabled", + "list_only", +} +var enumValues_P2PSettingsRespP2PSettingsLocalCurrenciesElemHasAdverts = []interface{}{ + 0, + 1, +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *P2PSettingsRespP2PSettingsLocalCurrenciesElemHasAdverts) UnmarshalJSON(b []byte) error { + var v int + if err := json.Unmarshal(b, &v); err != nil { + return err + } + var ok bool + for _, expected := range enumValues_P2PSettingsRespP2PSettingsLocalCurrenciesElemHasAdverts { + if reflect.DeepEqual(v, expected) { + ok = true + break + } + } + if !ok { + return fmt.Errorf("invalid value (expected one of %#v): %#v", enumValues_P2PSettingsRespP2PSettingsLocalCurrenciesElemHasAdverts, v) + } + *j = P2PSettingsRespP2PSettingsLocalCurrenciesElemHasAdverts(v) + return nil +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *P2PSettingsRespP2PSettingsFixedRateAdverts) UnmarshalJSON(b []byte) error { + var v string + if err := json.Unmarshal(b, &v); err != nil { + return err + } + var ok bool + for _, expected := range enumValues_P2PSettingsRespP2PSettingsFixedRateAdverts { + if reflect.DeepEqual(v, expected) { + ok = true + break + } + } + if !ok { + return fmt.Errorf("invalid value (expected one of %#v): %#v", enumValues_P2PSettingsRespP2PSettingsFixedRateAdverts, v) + } + *j = P2PSettingsRespP2PSettingsFixedRateAdverts(v) + return nil +} + +var enumValues_P2PSettingsRespP2PSettingsDisabled = []interface{}{ + 0, + 1, +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *P2PSettingsRespP2PSettingsDisabled) UnmarshalJSON(b []byte) error { + var v int + if err := json.Unmarshal(b, &v); err != nil { + return err + } + var ok bool + for _, expected := range enumValues_P2PSettingsRespP2PSettingsDisabled { + if reflect.DeepEqual(v, expected) { + ok = true + break + } + } + if !ok { + return fmt.Errorf("invalid value (expected one of %#v): %#v", enumValues_P2PSettingsRespP2PSettingsDisabled, v) + } + *j = P2PSettingsRespP2PSettingsDisabled(v) + return nil +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *P2PSettingsRespP2PSettingsBlockTradeDisabled) UnmarshalJSON(b []byte) error { + var v int + if err := json.Unmarshal(b, &v); err != nil { + return err + } + var ok bool + for _, expected := range enumValues_P2PSettingsRespP2PSettingsBlockTradeDisabled { + if reflect.DeepEqual(v, expected) { + ok = true + break + } + } + if !ok { + return fmt.Errorf("invalid value (expected one of %#v): %#v", enumValues_P2PSettingsRespP2PSettingsBlockTradeDisabled, v) + } + *j = P2PSettingsRespP2PSettingsBlockTradeDisabled(v) + return nil +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *P2PSettingsRespP2PSettingsLocalCurrenciesElem) UnmarshalJSON(b []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(b, &raw); err != nil { + return err + } + if v, ok := raw["display_name"]; !ok || v == nil { + return fmt.Errorf("field display_name in P2PSettingsRespP2PSettingsLocalCurrenciesElem: required") + } + if v, ok := raw["has_adverts"]; !ok || v == nil { + return fmt.Errorf("field has_adverts in P2PSettingsRespP2PSettingsLocalCurrenciesElem: required") + } + if v, ok := raw["symbol"]; !ok || v == nil { + return fmt.Errorf("field symbol in P2PSettingsRespP2PSettingsLocalCurrenciesElem: required") + } + type Plain P2PSettingsRespP2PSettingsLocalCurrenciesElem + var plain Plain + if err := json.Unmarshal(b, &plain); err != nil { + return err + } + *j = P2PSettingsRespP2PSettingsLocalCurrenciesElem(plain) + return nil +} + +type P2PSettingsRespP2PSettingsPaymentMethodsEnabled int + +var enumValues_P2PSettingsRespP2PSettingsPaymentMethodsEnabled = []interface{}{ + 0, + 1, +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *P2PSettingsRespP2PSettingsPaymentMethodsEnabled) UnmarshalJSON(b []byte) error { + var v int + if err := json.Unmarshal(b, &v); err != nil { + return err + } + var ok bool + for _, expected := range enumValues_P2PSettingsRespP2PSettingsPaymentMethodsEnabled { + if reflect.DeepEqual(v, expected) { + ok = true + break + } + } + if !ok { + return fmt.Errorf("invalid value (expected one of %#v): %#v", enumValues_P2PSettingsRespP2PSettingsPaymentMethodsEnabled, v) + } + *j = P2PSettingsRespP2PSettingsPaymentMethodsEnabled(v) + return nil +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *P2PSettingsRespMsgType) UnmarshalJSON(b []byte) error { + var v string + if err := json.Unmarshal(b, &v); err != nil { + return err + } + var ok bool + for _, expected := range enumValues_P2PSettingsRespMsgType { + if reflect.DeepEqual(v, expected) { + ok = true + break + } + } + if !ok { + return fmt.Errorf("invalid value (expected one of %#v): %#v", enumValues_P2PSettingsRespMsgType, v) + } + *j = P2PSettingsRespMsgType(v) + return nil +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *P2PSettingsRespP2PSettings) UnmarshalJSON(b []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(b, &raw); err != nil { + return err + } + if v, ok := raw["adverts_active_limit"]; !ok || v == nil { + return fmt.Errorf("field adverts_active_limit in P2PSettingsRespP2PSettings: required") + } + if v, ok := raw["block_trade"]; !ok || v == nil { + return fmt.Errorf("field block_trade in P2PSettingsRespP2PSettings: required") + } + if v, ok := raw["cancellation_block_duration"]; !ok || v == nil { + return fmt.Errorf("field cancellation_block_duration in P2PSettingsRespP2PSettings: required") + } + if v, ok := raw["cancellation_count_period"]; !ok || v == nil { + return fmt.Errorf("field cancellation_count_period in P2PSettingsRespP2PSettings: required") + } + if v, ok := raw["cancellation_grace_period"]; !ok || v == nil { + return fmt.Errorf("field cancellation_grace_period in P2PSettingsRespP2PSettings: required") + } + if v, ok := raw["cancellation_limit"]; !ok || v == nil { + return fmt.Errorf("field cancellation_limit in P2PSettingsRespP2PSettings: required") + } + if v, ok := raw["cross_border_ads_enabled"]; !ok || v == nil { + return fmt.Errorf("field cross_border_ads_enabled in P2PSettingsRespP2PSettings: required") + } + if v, ok := raw["disabled"]; !ok || v == nil { + return fmt.Errorf("field disabled in P2PSettingsRespP2PSettings: required") + } + if v, ok := raw["feature_level"]; !ok || v == nil { + return fmt.Errorf("field feature_level in P2PSettingsRespP2PSettings: required") + } + if v, ok := raw["fixed_rate_adverts"]; !ok || v == nil { + return fmt.Errorf("field fixed_rate_adverts in P2PSettingsRespP2PSettings: required") + } + if v, ok := raw["float_rate_adverts"]; !ok || v == nil { + return fmt.Errorf("field float_rate_adverts in P2PSettingsRespP2PSettings: required") + } + if v, ok := raw["float_rate_offset_limit"]; !ok || v == nil { + return fmt.Errorf("field float_rate_offset_limit in P2PSettingsRespP2PSettings: required") + } + if v, ok := raw["local_currencies"]; !ok || v == nil { + return fmt.Errorf("field local_currencies in P2PSettingsRespP2PSettings: required") + } + if v, ok := raw["maximum_advert_amount"]; !ok || v == nil { + return fmt.Errorf("field maximum_advert_amount in P2PSettingsRespP2PSettings: required") + } + if v, ok := raw["maximum_order_amount"]; !ok || v == nil { + return fmt.Errorf("field maximum_order_amount in P2PSettingsRespP2PSettings: required") + } + if v, ok := raw["order_daily_limit"]; !ok || v == nil { + return fmt.Errorf("field order_daily_limit in P2PSettingsRespP2PSettings: required") + } + if v, ok := raw["order_payment_period"]; !ok || v == nil { + return fmt.Errorf("field order_payment_period in P2PSettingsRespP2PSettings: required") + } + if v, ok := raw["payment_methods_enabled"]; !ok || v == nil { + return fmt.Errorf("field payment_methods_enabled in P2PSettingsRespP2PSettings: required") + } + if v, ok := raw["review_period"]; !ok || v == nil { + return fmt.Errorf("field review_period in P2PSettingsRespP2PSettings: required") + } + if v, ok := raw["supported_currencies"]; !ok || v == nil { + return fmt.Errorf("field supported_currencies in P2PSettingsRespP2PSettings: required") + } + type Plain P2PSettingsRespP2PSettings + var plain Plain + if err := json.Unmarshal(b, &plain); err != nil { + return err + } + *j = P2PSettingsRespP2PSettings(plain) + return nil +} + +// For subscription requests only. +type P2PSettingsRespSubscription struct { + // A per-connection unique identifier. Can be passed to the `forget` API call to + // unsubscribe. + Id string `json:"id"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *P2PSettingsRespSubscription) UnmarshalJSON(b []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(b, &raw); err != nil { + return err + } + if v, ok := raw["id"]; !ok || v == nil { + return fmt.Errorf("field id in P2PSettingsRespSubscription: required") + } + type Plain P2PSettingsRespSubscription + var plain Plain + if err := json.Unmarshal(b, &plain); err != nil { + return err + } + *j = P2PSettingsRespSubscription(plain) + return nil +} + +var enumValues_P2PSettingsRespMsgType = []interface{}{ + "p2p_settings", +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *P2PSettingsResp) 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 P2PSettingsResp: required") + } + if v, ok := raw["msg_type"]; !ok || v == nil { + return fmt.Errorf("field msg_type in P2PSettingsResp: required") + } + type Plain P2PSettingsResp + var plain Plain + if err := json.Unmarshal(b, &plain); err != nil { + return err + } + *j = P2PSettingsResp(plain) + return nil +} diff --git a/subscription_calls.go b/subscription_calls.go index 627f39a..42bf87b 100644 --- a/subscription_calls.go +++ b/subscription_calls.go @@ -103,6 +103,17 @@ func (a *DerivAPI) SubscribeP2POrderList(r schema.P2POrderList) (rsp schema.P2PO return } +// SubscribeP2PSettings Request P2P Settings information. +func (a *DerivAPI) SubscribeP2PSettings(r schema.P2PSettings) (rsp schema.P2PSettingsResp, s *Subsciption[schema.P2PSettingsResp, schema.P2PSettingsResp], err error) { + id := a.getNextRequestID() + var f schema.P2PSettingsSubscribe = 1 + r.ReqId = &id + r.Subscribe = &f + s = NewSubcription[schema.P2PSettingsResp, schema.P2PSettingsResp](a) + rsp, err = s.Start(id, r) + return +} + // SubscribeProposal Gets latest price for a specific contract. func (a *DerivAPI) SubscribeProposal(r schema.Proposal) (rsp schema.ProposalResp, s *Subsciption[schema.ProposalResp, schema.ProposalResp], err error) { id := a.getNextRequestID()