use serde::Serialize;
#[derive(Debug, Clone, Copy, Serialize)]
pub enum SubAccountType {
#[serde(rename = "6")]
Funding,
#[serde(rename = "18")]
Trading,
}
#[derive(Debug, Clone, Default, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct SubAccountListRequest {
#[serde(skip_serializing_if = "Option::is_none")]
enable: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
sub_acct: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
after: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
before: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
limit: Option<u32>,
}
impl SubAccountListRequest {
pub fn new() -> Self {
Self::default()
}
pub fn enable(mut self, enable: bool) -> Self {
self.enable = Some(enable);
self
}
pub fn sub_acct(mut self, sub_acct: impl Into<String>) -> Self {
self.sub_acct = Some(sub_acct.into());
self
}
pub fn after(mut self, after: impl Into<String>) -> Self {
self.after = Some(after.into());
self
}
pub fn before(mut self, before: impl Into<String>) -> Self {
self.before = Some(before.into());
self
}
pub fn limit(mut self, limit: u32) -> Self {
self.limit = Some(limit);
self
}
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct SubAccountApiKeysRequest {
sub_acct: String,
#[serde(skip_serializing_if = "Option::is_none")]
api_key: Option<String>,
}
impl SubAccountApiKeysRequest {
pub fn new(sub_acct: impl Into<String>) -> Self {
Self {
sub_acct: sub_acct.into(),
api_key: None,
}
}
pub fn api_key(mut self, api_key: impl Into<String>) -> Self {
self.api_key = Some(api_key.into());
self
}
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct SubAccountTradingBalancesRequest {
sub_acct: String,
}
impl SubAccountTradingBalancesRequest {
pub fn new(sub_acct: impl Into<String>) -> Self {
Self {
sub_acct: sub_acct.into(),
}
}
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct SubAccountFundingBalancesRequest {
sub_acct: String,
#[serde(skip_serializing_if = "Option::is_none")]
ccy: Option<String>,
}
impl SubAccountFundingBalancesRequest {
pub fn new(sub_acct: impl Into<String>) -> Self {
Self {
sub_acct: sub_acct.into(),
ccy: None,
}
}
pub fn ccy(mut self, ccy: impl Into<String>) -> Self {
self.ccy = Some(ccy.into());
self
}
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct SubAccountMaxWithdrawalRequest {
sub_acct: String,
#[serde(skip_serializing_if = "Option::is_none")]
ccy: Option<String>,
}
impl SubAccountMaxWithdrawalRequest {
pub fn new(sub_acct: impl Into<String>) -> Self {
Self {
sub_acct: sub_acct.into(),
ccy: None,
}
}
pub fn ccy(mut self, ccy: impl Into<String>) -> Self {
self.ccy = Some(ccy.into());
self
}
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CreateSubAccountRequest {
sub_acct: String,
#[serde(skip_serializing_if = "Option::is_none")]
r#type: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
label: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pwd: Option<String>,
}
impl CreateSubAccountRequest {
pub fn new(sub_acct: impl Into<String>) -> Self {
Self {
sub_acct: sub_acct.into(),
r#type: None,
label: None,
pwd: None,
}
}
pub fn sub_type(mut self, sub_type: impl Into<String>) -> Self {
self.r#type = Some(sub_type.into());
self
}
pub fn label(mut self, label: impl Into<String>) -> Self {
self.label = Some(label.into());
self
}
pub fn pwd(mut self, pwd: impl Into<String>) -> Self {
self.pwd = Some(pwd.into());
self
}
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CreateSubAccountApiKeyRequest {
sub_acct: String,
label: String,
passphrase: String,
#[serde(skip_serializing_if = "Option::is_none")]
perm: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
ip: Option<String>,
}
impl CreateSubAccountApiKeyRequest {
pub fn new(
sub_acct: impl Into<String>,
label: impl Into<String>,
passphrase: impl Into<String>,
) -> Self {
Self {
sub_acct: sub_acct.into(),
label: label.into(),
passphrase: passphrase.into(),
perm: None,
ip: None,
}
}
pub fn perm(mut self, perm: impl Into<String>) -> Self {
self.perm = Some(perm.into());
self
}
pub fn ip(mut self, ip: impl Into<String>) -> Self {
self.ip = Some(ip.into());
self
}
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct ModifySubAccountApiKeyRequest {
sub_acct: String,
api_key: String,
#[serde(skip_serializing_if = "Option::is_none")]
label: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
perm: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
ip: Option<String>,
}
impl ModifySubAccountApiKeyRequest {
pub fn new(sub_acct: impl Into<String>, api_key: impl Into<String>) -> Self {
Self {
sub_acct: sub_acct.into(),
api_key: api_key.into(),
label: None,
perm: None,
ip: None,
}
}
pub fn label(mut self, label: impl Into<String>) -> Self {
self.label = Some(label.into());
self
}
pub fn perm(mut self, perm: impl Into<String>) -> Self {
self.perm = Some(perm.into());
self
}
pub fn ip(mut self, ip: impl Into<String>) -> Self {
self.ip = Some(ip.into());
self
}
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct DeleteSubAccountApiKeyRequest {
sub_acct: String,
api_key: String,
}
impl DeleteSubAccountApiKeyRequest {
pub fn new(sub_acct: impl Into<String>, api_key: impl Into<String>) -> Self {
Self {
sub_acct: sub_acct.into(),
api_key: api_key.into(),
}
}
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct SubAccountTransferRequest {
ccy: String,
amt: String,
from: SubAccountType,
to: SubAccountType,
from_sub_account: String,
to_sub_account: String,
#[serde(skip_serializing_if = "Option::is_none")]
loan_trans: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
omit_pos_risk: Option<String>,
}
impl SubAccountTransferRequest {
pub fn new(
ccy: impl Into<String>,
amt: impl Into<String>,
from: SubAccountType,
to: SubAccountType,
from_sub_account: impl Into<String>,
to_sub_account: impl Into<String>,
) -> Self {
Self {
ccy: ccy.into(),
amt: amt.into(),
from,
to,
from_sub_account: from_sub_account.into(),
to_sub_account: to_sub_account.into(),
loan_trans: None,
omit_pos_risk: None,
}
}
pub fn loan_trans(mut self, loan_trans: bool) -> Self {
self.loan_trans = Some(loan_trans);
self
}
pub fn omit_pos_risk(mut self, omit_pos_risk: impl Into<String>) -> Self {
self.omit_pos_risk = Some(omit_pos_risk.into());
self
}
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct SetTransferOutRequest {
sub_acct: String,
can_trans_out: bool,
}
impl SetTransferOutRequest {
pub fn new(sub_acct: impl Into<String>) -> Self {
Self {
sub_acct: sub_acct.into(),
can_trans_out: true,
}
}
pub fn can_trans_out(mut self, can_trans_out: bool) -> Self {
self.can_trans_out = can_trans_out;
self
}
}
#[derive(Debug, Clone, Default, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct SubAccountBillsRequest {
#[serde(skip_serializing_if = "Option::is_none")]
ccy: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
r#type: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
sub_acct: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
after: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
before: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
limit: Option<u32>,
}
impl SubAccountBillsRequest {
pub fn new() -> Self {
Self::default()
}
pub fn ccy(mut self, ccy: impl Into<String>) -> Self {
self.ccy = Some(ccy.into());
self
}
pub fn bill_type(mut self, r#type: impl Into<String>) -> Self {
self.r#type = Some(r#type.into());
self
}
pub fn sub_acct(mut self, sub_acct: impl Into<String>) -> Self {
self.sub_acct = Some(sub_acct.into());
self
}
pub fn after(mut self, after: impl Into<String>) -> Self {
self.after = Some(after.into());
self
}
pub fn before(mut self, before: impl Into<String>) -> Self {
self.before = Some(before.into());
self
}
pub fn limit(mut self, limit: u32) -> Self {
self.limit = Some(limit);
self
}
}
#[derive(Debug, Clone, Default, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct ManagedSubAccountBillsRequest {
#[serde(skip_serializing_if = "Option::is_none")]
ccy: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
r#type: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
sub_acct: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
sub_uid: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
after: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
before: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
limit: Option<u32>,
}
impl ManagedSubAccountBillsRequest {
pub fn new() -> Self {
Self::default()
}
pub fn ccy(mut self, ccy: impl Into<String>) -> Self {
self.ccy = Some(ccy.into());
self
}
pub fn bill_type(mut self, r#type: impl Into<String>) -> Self {
self.r#type = Some(r#type.into());
self
}
pub fn sub_acct(mut self, sub_acct: impl Into<String>) -> Self {
self.sub_acct = Some(sub_acct.into());
self
}
pub fn sub_uid(mut self, sub_uid: impl Into<String>) -> Self {
self.sub_uid = Some(sub_uid.into());
self
}
pub fn after(mut self, after: impl Into<String>) -> Self {
self.after = Some(after.into());
self
}
pub fn before(mut self, before: impl Into<String>) -> Self {
self.before = Some(before.into());
self
}
pub fn limit(mut self, limit: u32) -> Self {
self.limit = Some(limit);
self
}
}
#[derive(Debug, Clone, Default, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct EntrustSubAccountListRequest {
#[serde(skip_serializing_if = "Option::is_none")]
sub_acct: Option<String>,
}