Skip to main content

rust_okx/api/account/requests/
settings.rs

1use std::borrow::Cow;
2
3use serde::Serialize;
4
5/// Request for [`set_position_mode`](crate::api::account::Account::set_position_mode).
6#[derive(Debug, Clone, Serialize)]
7pub struct SetPositionModeRequest<'a> {
8    #[serde(rename = "posMode")]
9    pos_mode: Cow<'a, str>,
10}
11
12impl<'a> SetPositionModeRequest<'a> {
13    /// Create a position-mode update.
14    pub fn new(pos_mode: impl Into<Cow<'a, str>>) -> Self {
15        Self {
16            pos_mode: pos_mode.into(),
17        }
18    }
19}
20
21/// Request for [`set_greeks`](crate::api::account::Account::set_greeks).
22#[derive(Debug, Clone, Serialize)]
23pub struct SetGreeksRequest<'a> {
24    #[serde(rename = "greeksType")]
25    greeks_type: Cow<'a, str>,
26}
27
28impl<'a> SetGreeksRequest<'a> {
29    /// Create a greeks-display update.
30    pub fn new(greeks_type: impl Into<Cow<'a, str>>) -> Self {
31        Self {
32            greeks_type: greeks_type.into(),
33        }
34    }
35}
36
37/// Request for [`set_isolated_mode`](crate::api::account::Account::set_isolated_mode).
38#[derive(Debug, Clone, Serialize)]
39pub struct SetIsolatedModeRequest<'a> {
40    #[serde(rename = "isoMode")]
41    iso_mode: Cow<'a, str>,
42    #[serde(rename = "type")]
43    mode_type: Cow<'a, str>,
44}
45
46impl<'a> SetIsolatedModeRequest<'a> {
47    /// Create an isolated-mode update.
48    pub fn new(iso_mode: impl Into<Cow<'a, str>>, mode_type: impl Into<Cow<'a, str>>) -> Self {
49        Self {
50            iso_mode: iso_mode.into(),
51            mode_type: mode_type.into(),
52        }
53    }
54}
55
56/// Request for [`set_auto_loan`](crate::api::account::Account::set_auto_loan).
57#[derive(Debug, Clone, Serialize)]
58pub struct SetAutoLoanRequest {
59    #[serde(rename = "autoLoan")]
60    auto_loan: bool,
61}
62
63impl SetAutoLoanRequest {
64    /// Create an auto-loan update.
65    pub fn new(auto_loan: bool) -> Self {
66        Self { auto_loan }
67    }
68}
69
70/// Request for [`set_account_level`](crate::api::account::Account::set_account_level).
71#[derive(Debug, Clone, Serialize)]
72pub struct SetAccountLevelRequest<'a> {
73    #[serde(rename = "acctLv")]
74    acct_lv: Cow<'a, str>,
75}
76
77impl<'a> SetAccountLevelRequest<'a> {
78    /// Create an account-level update.
79    pub fn new(acct_lv: impl Into<Cow<'a, str>>) -> Self {
80        Self {
81            acct_lv: acct_lv.into(),
82        }
83    }
84}