use serde::Serialize;
use whisky::Asset;
use crate::{Interval, OrderRecordStatus, Symbol, TransferalType};
#[derive(Debug, Serialize)]
pub struct OrderRecordParams {
pub status: OrderRecordStatus,
#[serde(skip_serializing_if = "Option::is_none")]
pub limit: Option<u32>,
#[serde(skip_serializing_if = "Option::is_none")]
pub page: Option<u32>,
#[serde(skip_serializing_if = "Option::is_none")]
pub symbol: Option<String>,
}
impl OrderRecordParams {
pub fn new(status: OrderRecordStatus) -> Self {
Self {
status,
limit: None,
page: None,
symbol: None,
}
}
pub fn with_limit(mut self, limit: u32) -> Self {
self.limit = Some(limit);
self
}
pub fn with_page(mut self, page: u32) -> Self {
self.page = Some(page);
self
}
pub fn with_symbol(mut self, symbol: String) -> Self {
self.symbol = Some(symbol);
self
}
}
#[derive(Debug, Serialize)]
pub struct GetAggregatedPriceRequest {
pub symbol: Symbol,
pub interval: Interval,
pub start: i64,
pub end: i64,
}
#[derive(Debug, Serialize, Default, Clone)]
pub struct BuildWithdrawalTransactionRequest {
pub withdrawal_amount: Vec<Asset>,
#[serde(skip_serializing_if = "Option::is_none")]
pub withdraw_type: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub vault_id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub from_account_id: Option<String>,
}
impl BuildWithdrawalTransactionRequest {
pub fn new(withdrawal_amount: Vec<Asset>) -> Self {
Self {
withdrawal_amount,
withdraw_type: None,
vault_id: None,
from_account_id: None,
}
}
pub fn new_vault(withdrawal_amount: Vec<Asset>, vault_id: impl Into<String>) -> Self {
Self {
withdrawal_amount,
withdraw_type: Some("vault".to_string()),
vault_id: Some(vault_id.into()),
from_account_id: None,
}
}
pub fn with_from_account_id(mut self, from_account_id: impl Into<String>) -> Self {
self.from_account_id = Some(from_account_id.into());
self
}
}
#[derive(Debug, Serialize, Default, Clone)]
pub struct BuildTransferalTransactionRequest {
pub transferal_amount: Vec<Asset>,
#[serde(skip_serializing_if = "Option::is_none")]
pub to_address: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub to_account_id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub transferal_type: Option<TransferalType>,
#[serde(skip_serializing_if = "Option::is_none")]
pub vault_id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub from_account_id: Option<String>,
}
impl BuildTransferalTransactionRequest {
pub fn to_address(transferal_amount: Vec<Asset>, to_address: impl Into<String>) -> Self {
Self {
transferal_amount,
to_address: Some(to_address.into()),
..Default::default()
}
}
pub fn to_account_id(transferal_amount: Vec<Asset>, to_account_id: impl Into<String>) -> Self {
Self {
transferal_amount,
to_account_id: Some(to_account_id.into()),
..Default::default()
}
}
pub fn with_transferal_type(mut self, transferal_type: TransferalType) -> Self {
self.transferal_type = Some(transferal_type);
self
}
pub fn with_vault_id(mut self, vault_id: impl Into<String>) -> Self {
self.vault_id = Some(vault_id.into());
self
}
pub fn with_from_account_id(mut self, from_account_id: impl Into<String>) -> Self {
self.from_account_id = Some(from_account_id.into());
self
}
}