use std::borrow::Cow;
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<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
enable: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
sub_acct: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
after: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
before: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
limit: Option<u32>,
}
impl<'a> SubAccountListRequest<'a> {
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<Cow<'a, str>>) -> Self {
self.sub_acct = Some(sub_acct.into());
self
}
pub fn after(mut self, after: impl Into<Cow<'a, str>>) -> Self {
self.after = Some(after.into());
self
}
pub fn before(mut self, before: impl Into<Cow<'a, str>>) -> 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<'a> {
sub_acct: Cow<'a, str>,
#[serde(skip_serializing_if = "Option::is_none")]
api_key: Option<Cow<'a, str>>,
}
impl<'a> SubAccountApiKeysRequest<'a> {
pub fn new(sub_acct: impl Into<Cow<'a, str>>) -> Self {
Self {
sub_acct: sub_acct.into(),
api_key: None,
}
}
pub fn api_key(mut self, api_key: impl Into<Cow<'a, str>>) -> Self {
self.api_key = Some(api_key.into());
self
}
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct SubAccountTradingBalancesRequest<'a> {
sub_acct: Cow<'a, str>,
}
impl<'a> SubAccountTradingBalancesRequest<'a> {
pub fn new(sub_acct: impl Into<Cow<'a, str>>) -> Self {
Self {
sub_acct: sub_acct.into(),
}
}
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct SubAccountFundingBalancesRequest<'a> {
sub_acct: Cow<'a, str>,
#[serde(skip_serializing_if = "Option::is_none")]
ccy: Option<Cow<'a, str>>,
}
impl<'a> SubAccountFundingBalancesRequest<'a> {
pub fn new(sub_acct: impl Into<Cow<'a, str>>) -> Self {
Self {
sub_acct: sub_acct.into(),
ccy: None,
}
}
pub fn ccy(mut self, ccy: impl Into<Cow<'a, str>>) -> Self {
self.ccy = Some(ccy.into());
self
}
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct SubAccountMaxWithdrawalRequest<'a> {
sub_acct: Cow<'a, str>,
#[serde(skip_serializing_if = "Option::is_none")]
ccy: Option<Cow<'a, str>>,
}
impl<'a> SubAccountMaxWithdrawalRequest<'a> {
pub fn new(sub_acct: impl Into<Cow<'a, str>>) -> Self {
Self {
sub_acct: sub_acct.into(),
ccy: None,
}
}
pub fn ccy(mut self, ccy: impl Into<Cow<'a, str>>) -> Self {
self.ccy = Some(ccy.into());
self
}
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CreateSubAccountRequest<'a> {
sub_acct: Cow<'a, str>,
#[serde(skip_serializing_if = "Option::is_none")]
r#type: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
label: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
pwd: Option<String>,
}
impl<'a> CreateSubAccountRequest<'a> {
pub fn new(sub_acct: impl Into<Cow<'a, str>>) -> Self {
Self {
sub_acct: sub_acct.into(),
r#type: None,
label: None,
pwd: None,
}
}
pub fn sub_type(mut self, sub_type: impl Into<Cow<'a, str>>) -> Self {
self.r#type = Some(sub_type.into());
self
}
pub fn label(mut self, label: impl Into<Cow<'a, str>>) -> 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<'a> {
sub_acct: Cow<'a, str>,
label: Cow<'a, str>,
passphrase: String,
#[serde(skip_serializing_if = "Option::is_none")]
perm: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
ip: Option<Cow<'a, str>>,
}
impl<'a> CreateSubAccountApiKeyRequest<'a> {
pub fn new(
sub_acct: impl Into<Cow<'a, str>>,
label: impl Into<Cow<'a, str>>,
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<Cow<'a, str>>) -> Self {
self.perm = Some(perm.into());
self
}
pub fn ip(mut self, ip: impl Into<Cow<'a, str>>) -> Self {
self.ip = Some(ip.into());
self
}
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct ModifySubAccountApiKeyRequest<'a> {
sub_acct: Cow<'a, str>,
api_key: Cow<'a, str>,
#[serde(skip_serializing_if = "Option::is_none")]
label: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
perm: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
ip: Option<Cow<'a, str>>,
}
impl<'a> ModifySubAccountApiKeyRequest<'a> {
pub fn new(sub_acct: impl Into<Cow<'a, str>>, api_key: impl Into<Cow<'a, str>>) -> 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<Cow<'a, str>>) -> Self {
self.label = Some(label.into());
self
}
pub fn perm(mut self, perm: impl Into<Cow<'a, str>>) -> Self {
self.perm = Some(perm.into());
self
}
pub fn ip(mut self, ip: impl Into<Cow<'a, str>>) -> Self {
self.ip = Some(ip.into());
self
}
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct DeleteSubAccountApiKeyRequest<'a> {
sub_acct: Cow<'a, str>,
api_key: Cow<'a, str>,
}
impl<'a> DeleteSubAccountApiKeyRequest<'a> {
pub fn new(sub_acct: impl Into<Cow<'a, str>>, api_key: impl Into<Cow<'a, str>>) -> Self {
Self {
sub_acct: sub_acct.into(),
api_key: api_key.into(),
}
}
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct SubAccountTransferRequest<'a> {
ccy: Cow<'a, str>,
amt: Cow<'a, str>,
from: SubAccountType,
to: SubAccountType,
from_sub_account: Cow<'a, str>,
to_sub_account: Cow<'a, str>,
#[serde(skip_serializing_if = "Option::is_none")]
loan_trans: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
omit_pos_risk: Option<bool>,
}
impl<'a> SubAccountTransferRequest<'a> {
pub fn new(
ccy: impl Into<Cow<'a, str>>,
amt: impl Into<Cow<'a, str>>,
from: SubAccountType,
to: SubAccountType,
from_sub_account: impl Into<Cow<'a, str>>,
to_sub_account: impl Into<Cow<'a, str>>,
) -> 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: bool) -> Self {
self.omit_pos_risk = Some(omit_pos_risk);
self
}
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct SetTransferOutRequest<'a> {
sub_acct: Cow<'a, str>,
can_trans_out: bool,
}
impl<'a> SetTransferOutRequest<'a> {
pub fn new(sub_acct: impl Into<Cow<'a, str>>) -> 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<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
ccy: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
r#type: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
sub_acct: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
after: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
before: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
limit: Option<u32>,
}
impl<'a> SubAccountBillsRequest<'a> {
pub fn new() -> Self {
Self::default()
}
pub fn ccy(mut self, ccy: impl Into<Cow<'a, str>>) -> Self {
self.ccy = Some(ccy.into());
self
}
pub fn bill_type(mut self, r#type: impl Into<Cow<'a, str>>) -> Self {
self.r#type = Some(r#type.into());
self
}
pub fn sub_acct(mut self, sub_acct: impl Into<Cow<'a, str>>) -> Self {
self.sub_acct = Some(sub_acct.into());
self
}
pub fn after(mut self, after: impl Into<Cow<'a, str>>) -> Self {
self.after = Some(after.into());
self
}
pub fn before(mut self, before: impl Into<Cow<'a, str>>) -> 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<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
ccy: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
r#type: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
sub_acct: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
sub_uid: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
after: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
before: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
limit: Option<u32>,
}
impl<'a> ManagedSubAccountBillsRequest<'a> {
pub fn new() -> Self {
Self::default()
}
pub fn ccy(mut self, ccy: impl Into<Cow<'a, str>>) -> Self {
self.ccy = Some(ccy.into());
self
}
pub fn bill_type(mut self, r#type: impl Into<Cow<'a, str>>) -> Self {
self.r#type = Some(r#type.into());
self
}
pub fn sub_acct(mut self, sub_acct: impl Into<Cow<'a, str>>) -> Self {
self.sub_acct = Some(sub_acct.into());
self
}
pub fn sub_uid(mut self, sub_uid: impl Into<Cow<'a, str>>) -> Self {
self.sub_uid = Some(sub_uid.into());
self
}
pub fn after(mut self, after: impl Into<Cow<'a, str>>) -> Self {
self.after = Some(after.into());
self
}
pub fn before(mut self, before: impl Into<Cow<'a, str>>) -> 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<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
sub_acct: Option<Cow<'a, str>>,
}