use std::borrow::Cow;
use serde::Serialize;
#[derive(Debug, Clone, Default, Serialize)]
pub struct CurrencyRequest<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
ccy: Option<Cow<'a, str>>,
}
impl<'a> CurrencyRequest<'a> {
pub fn new() -> Self {
Self::default()
}
pub fn currency(mut self, ccy: impl Into<Cow<'a, str>>) -> Self {
self.ccy = Some(ccy.into());
self
}
}
#[derive(Debug, Clone, Serialize)]
pub struct DepositAddressRequest<'a> {
ccy: Cow<'a, str>,
}
impl<'a> DepositAddressRequest<'a> {
pub fn new(ccy: impl Into<Cow<'a, str>>) -> Self {
Self { ccy: ccy.into() }
}
}
#[derive(Debug, Clone, Serialize)]
pub struct TransferStateRequest<'a> {
#[serde(rename = "transId", skip_serializing_if = "Option::is_none")]
trans_id: Option<Cow<'a, str>>,
#[serde(rename = "clientId", skip_serializing_if = "Option::is_none")]
client_id: Option<Cow<'a, str>>,
#[serde(rename = "type", skip_serializing_if = "Option::is_none")]
transfer_type: Option<Cow<'a, str>>,
}
impl<'a> TransferStateRequest<'a> {
pub fn new(trans_id: impl Into<Cow<'a, str>>) -> Self {
Self {
trans_id: Some(trans_id.into()),
client_id: None,
transfer_type: None,
}
}
pub fn with_client_id(client_id: impl Into<Cow<'a, str>>) -> Self {
Self {
trans_id: None,
client_id: Some(client_id.into()),
transfer_type: None,
}
}
pub fn client_id(mut self, client_id: impl Into<Cow<'a, str>>) -> Self {
self.client_id = Some(client_id.into());
self
}
pub fn transfer_type(mut self, transfer_type: impl Into<Cow<'a, str>>) -> Self {
self.transfer_type = Some(transfer_type.into());
self
}
}
#[derive(Debug, Clone, Serialize)]
pub struct CancelWithdrawalRequest<'a> {
#[serde(rename = "wdId")]
wd_id: Cow<'a, str>,
}
impl<'a> CancelWithdrawalRequest<'a> {
pub fn new(wd_id: impl Into<Cow<'a, str>>) -> Self {
Self {
wd_id: wd_id.into(),
}
}
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct FundsTransferRequest<'a> {
ccy: Cow<'a, str>,
amt: Cow<'a, str>,
#[serde(rename = "from")]
from_account: Cow<'a, str>,
to: Cow<'a, str>,
#[serde(rename = "type", skip_serializing_if = "Option::is_none")]
transfer_type: Option<Cow<'a, str>>,
#[serde(rename = "subAcct", skip_serializing_if = "Option::is_none")]
sub_account: Option<Cow<'a, str>>,
#[serde(rename = "loanTrans", skip_serializing_if = "Option::is_none")]
loan_transfer: Option<Cow<'a, str>>,
#[serde(rename = "omitPosRisk", skip_serializing_if = "Option::is_none")]
omit_pos_risk: Option<Cow<'a, str>>,
#[serde(rename = "clientId", skip_serializing_if = "Option::is_none")]
client_id: Option<Cow<'a, str>>,
}
impl<'a> FundsTransferRequest<'a> {
pub fn new(
ccy: impl Into<Cow<'a, str>>,
amt: impl Into<Cow<'a, str>>,
from_account: impl Into<Cow<'a, str>>,
to: impl Into<Cow<'a, str>>,
) -> Self {
Self {
ccy: ccy.into(),
amt: amt.into(),
from_account: from_account.into(),
to: to.into(),
transfer_type: None,
sub_account: None,
loan_transfer: None,
omit_pos_risk: None,
client_id: None,
}
}
pub fn transfer_type(mut self, transfer_type: impl Into<Cow<'a, str>>) -> Self {
self.transfer_type = Some(transfer_type.into());
self
}
pub fn sub_account(mut self, sub_account: impl Into<Cow<'a, str>>) -> Self {
self.sub_account = Some(sub_account.into());
self
}
pub fn loan_transfer(mut self, loan_transfer: impl Into<Cow<'a, str>>) -> Self {
self.loan_transfer = Some(loan_transfer.into());
self
}
pub fn omit_pos_risk(mut self, omit_pos_risk: impl Into<Cow<'a, str>>) -> Self {
self.omit_pos_risk = Some(omit_pos_risk.into());
self
}
pub fn client_id(mut self, client_id: impl Into<Cow<'a, str>>) -> Self {
self.client_id = Some(client_id.into());
self
}
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct WithdrawalRequest<'a> {
ccy: Cow<'a, str>,
amt: Cow<'a, str>,
dest: Cow<'a, str>,
#[serde(rename = "toAddr")]
to_addr: Cow<'a, str>,
#[serde(skip_serializing_if = "Option::is_none")]
chain: Option<Cow<'a, str>>,
#[serde(rename = "areaCode", skip_serializing_if = "Option::is_none")]
area_code: Option<Cow<'a, str>>,
#[serde(rename = "clientId", skip_serializing_if = "Option::is_none")]
client_id: Option<Cow<'a, str>>,
#[serde(rename = "toAddrType", skip_serializing_if = "Option::is_none")]
to_addr_type: Option<Cow<'a, str>>,
}
impl<'a> WithdrawalRequest<'a> {
pub fn new(
ccy: impl Into<Cow<'a, str>>,
amt: impl Into<Cow<'a, str>>,
dest: impl Into<Cow<'a, str>>,
to_addr: impl Into<Cow<'a, str>>,
) -> Self {
Self {
ccy: ccy.into(),
amt: amt.into(),
dest: dest.into(),
to_addr: to_addr.into(),
chain: None,
area_code: None,
client_id: None,
to_addr_type: None,
}
}
pub fn chain(mut self, chain: impl Into<Cow<'a, str>>) -> Self {
self.chain = Some(chain.into());
self
}
pub fn area_code(mut self, area_code: impl Into<Cow<'a, str>>) -> Self {
self.area_code = Some(area_code.into());
self
}
pub fn client_id(mut self, client_id: impl Into<Cow<'a, str>>) -> Self {
self.client_id = Some(client_id.into());
self
}
pub fn to_addr_type(mut self, to_addr_type: impl Into<Cow<'a, str>>) -> Self {
self.to_addr_type = Some(to_addr_type.into());
self
}
}
#[derive(Debug, Clone, Default, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct DepositHistoryRequest<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
ccy: Option<Cow<'a, str>>,
#[serde(rename = "type", skip_serializing_if = "Option::is_none")]
deposit_type: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
state: 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>,
#[serde(rename = "txId", skip_serializing_if = "Option::is_none")]
tx_id: Option<Cow<'a, str>>,
#[serde(rename = "depId", skip_serializing_if = "Option::is_none")]
dep_id: Option<Cow<'a, str>>,
#[serde(rename = "fromWdId", skip_serializing_if = "Option::is_none")]
from_wd_id: Option<Cow<'a, str>>,
}
impl<'a> DepositHistoryRequest<'a> {
pub fn new() -> Self {
Self::default()
}
pub fn currency(mut self, ccy: impl Into<Cow<'a, str>>) -> Self {
self.ccy = Some(ccy.into());
self
}
pub fn deposit_type(mut self, deposit_type: impl Into<Cow<'a, str>>) -> Self {
self.deposit_type = Some(deposit_type.into());
self
}
pub fn state(mut self, state: impl Into<Cow<'a, str>>) -> Self {
self.state = Some(state.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
}
pub fn tx_id(mut self, tx_id: impl Into<Cow<'a, str>>) -> Self {
self.tx_id = Some(tx_id.into());
self
}
pub fn dep_id(mut self, dep_id: impl Into<Cow<'a, str>>) -> Self {
self.dep_id = Some(dep_id.into());
self
}
pub fn from_wd_id(mut self, from_wd_id: impl Into<Cow<'a, str>>) -> Self {
self.from_wd_id = Some(from_wd_id.into());
self
}
}
#[derive(Debug, Clone, Default, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct WithdrawalHistoryRequest<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
ccy: Option<Cow<'a, str>>,
#[serde(rename = "wdId", skip_serializing_if = "Option::is_none")]
wd_id: Option<Cow<'a, str>>,
#[serde(rename = "clientId", skip_serializing_if = "Option::is_none")]
client_id: Option<Cow<'a, str>>,
#[serde(rename = "txId", skip_serializing_if = "Option::is_none")]
tx_id: Option<Cow<'a, str>>,
#[serde(rename = "type", skip_serializing_if = "Option::is_none")]
withdrawal_type: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
state: 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>,
#[serde(rename = "toAddrType", skip_serializing_if = "Option::is_none")]
to_addr_type: Option<Cow<'a, str>>,
}
impl<'a> WithdrawalHistoryRequest<'a> {
pub fn new() -> Self {
Self::default()
}
pub fn currency(mut self, ccy: impl Into<Cow<'a, str>>) -> Self {
self.ccy = Some(ccy.into());
self
}
pub fn withdrawal_id(mut self, wd_id: impl Into<Cow<'a, str>>) -> Self {
self.wd_id = Some(wd_id.into());
self
}
pub fn client_id(mut self, client_id: impl Into<Cow<'a, str>>) -> Self {
self.client_id = Some(client_id.into());
self
}
pub fn tx_id(mut self, tx_id: impl Into<Cow<'a, str>>) -> Self {
self.tx_id = Some(tx_id.into());
self
}
pub fn withdrawal_type(mut self, withdrawal_type: impl Into<Cow<'a, str>>) -> Self {
self.withdrawal_type = Some(withdrawal_type.into());
self
}
pub fn state(mut self, state: impl Into<Cow<'a, str>>) -> Self {
self.state = Some(state.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
}
pub fn to_addr_type(mut self, to_addr_type: impl Into<Cow<'a, str>>) -> Self {
self.to_addr_type = Some(to_addr_type.into());
self
}
}
#[derive(Debug, Clone, Default, Serialize)]
pub struct FundingBillsRequest<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
ccy: Option<Cow<'a, str>>,
#[serde(rename = "type", skip_serializing_if = "Option::is_none")]
bill_type: 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> FundingBillsRequest<'a> {
pub fn new() -> Self {
Self::default()
}
pub fn currency(mut self, ccy: impl Into<Cow<'a, str>>) -> Self {
self.ccy = Some(ccy.into());
self
}
pub fn bill_type(mut self, bill_type: impl Into<Cow<'a, str>>) -> Self {
self.bill_type = Some(bill_type.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)]
pub struct DepositLightningRequest<'a> {
ccy: Cow<'a, str>,
amt: Cow<'a, str>,
#[serde(skip_serializing_if = "Option::is_none")]
to: Option<Cow<'a, str>>,
}
impl<'a> DepositLightningRequest<'a> {
pub fn new(ccy: impl Into<Cow<'a, str>>, amt: impl Into<Cow<'a, str>>) -> Self {
Self {
ccy: ccy.into(),
amt: amt.into(),
to: None,
}
}
pub fn to(mut self, to: impl Into<Cow<'a, str>>) -> Self {
self.to = Some(to.into());
self
}
}
#[derive(Debug, Clone, Serialize)]
pub struct WithdrawalLightningRequest<'a> {
ccy: Cow<'a, str>,
invoice: Cow<'a, str>,
#[serde(skip_serializing_if = "Option::is_none")]
memo: Option<Cow<'a, str>>,
}
impl<'a> WithdrawalLightningRequest<'a> {
pub fn new(ccy: impl Into<Cow<'a, str>>, invoice: impl Into<Cow<'a, str>>) -> Self {
Self {
ccy: ccy.into(),
invoice: invoice.into(),
memo: None,
}
}
pub fn memo(mut self, memo: impl Into<Cow<'a, str>>) -> Self {
self.memo = Some(memo.into());
self
}
}
#[derive(Debug, Clone, Default, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct DepositWithdrawStatusRequest<'a> {
#[serde(rename = "wdId", skip_serializing_if = "Option::is_none")]
wd_id: Option<Cow<'a, str>>,
#[serde(rename = "txId", skip_serializing_if = "Option::is_none")]
tx_id: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
ccy: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
to: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
chain: Option<Cow<'a, str>>,
}
impl<'a> DepositWithdrawStatusRequest<'a> {
pub fn new() -> Self {
Self::default()
}
pub fn withdrawal_id(mut self, wd_id: impl Into<Cow<'a, str>>) -> Self {
self.wd_id = Some(wd_id.into());
self
}
pub fn tx_id(mut self, tx_id: impl Into<Cow<'a, str>>) -> Self {
self.tx_id = Some(tx_id.into());
self
}
pub fn currency(mut self, ccy: impl Into<Cow<'a, str>>) -> Self {
self.ccy = Some(ccy.into());
self
}
pub fn to(mut self, to: impl Into<Cow<'a, str>>) -> Self {
self.to = Some(to.into());
self
}
pub fn chain(mut self, chain: impl Into<Cow<'a, str>>) -> Self {
self.chain = Some(chain.into());
self
}
}