use serde::Serialize;
#[derive(Debug, Clone, Serialize)]
pub struct EasyConvertRequest {
#[serde(rename = "fromCcy")]
from_ccy: Vec<String>,
#[serde(rename = "toCcy")]
to_ccy: String,
#[serde(skip_serializing_if = "Option::is_none")]
source: Option<String>,
}
impl EasyConvertRequest {
pub fn new<I, S>(from_ccy: I, to_ccy: impl Into<String>) -> Self
where
I: IntoIterator<Item = S>,
S: Into<String>,
{
Self {
from_ccy: from_ccy.into_iter().map(Into::into).collect(),
to_ccy: to_ccy.into(),
source: None,
}
}
pub fn source(mut self, value: impl Into<String>) -> Self {
self.source = Some(value.into());
self
}
}
#[derive(Debug, Clone, Default, Serialize)]
pub struct EasyConvertHistoryRequest {
#[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 EasyConvertHistoryRequest {
pub fn new() -> Self {
Self::default()
}
pub fn after(mut self, value: impl Into<String>) -> Self {
self.after = Some(value.into());
self
}
pub fn before(mut self, value: impl Into<String>) -> Self {
self.before = Some(value.into());
self
}
pub fn limit(mut self, value: u32) -> Self {
self.limit = Some(value);
self
}
}
#[derive(Debug, Clone, Default, Serialize)]
pub struct OneClickRepayCurrencyListRequest {
#[serde(rename = "debtType", skip_serializing_if = "Option::is_none")]
debt_type: Option<String>,
}
impl OneClickRepayCurrencyListRequest {
pub fn new() -> Self {
Self::default()
}
pub fn debt_type(mut self, value: impl Into<String>) -> Self {
self.debt_type = Some(value.into());
self
}
}
#[derive(Debug, Clone, Serialize)]
#[serde(untagged)]
enum DebtCurrencySelection {
One(String),
Many(Vec<String>),
}
#[derive(Debug, Clone, Serialize)]
pub struct OneClickRepayRequest {
#[serde(rename = "debtCcy")]
debt_ccy: DebtCurrencySelection,
#[serde(rename = "repayCcy", skip_serializing_if = "Option::is_none")]
repay_ccy: Option<String>,
#[serde(rename = "repayCcyList", skip_serializing_if = "Option::is_none")]
repay_ccy_list: Option<Vec<String>>,
}
impl OneClickRepayRequest {
pub fn new<I, S>(debt_ccy: I, repay_ccy: impl Into<String>) -> Self
where
I: IntoIterator<Item = S>,
S: Into<String>,
{
Self {
debt_ccy: DebtCurrencySelection::Many(debt_ccy.into_iter().map(Into::into).collect()),
repay_ccy: Some(repay_ccy.into()),
repay_ccy_list: None,
}
}
pub fn v2<I, S>(debt_ccy: impl Into<String>, repay_ccy_list: I) -> Self
where
I: IntoIterator<Item = S>,
S: Into<String>,
{
Self {
debt_ccy: DebtCurrencySelection::One(debt_ccy.into()),
repay_ccy: None,
repay_ccy_list: Some(repay_ccy_list.into_iter().map(Into::into).collect()),
}
}
}
#[derive(Debug, Clone, Default, Serialize)]
pub struct OneClickRepayHistoryRequest {
#[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 OneClickRepayHistoryRequest {
pub fn new() -> Self {
Self::default()
}
pub fn after(mut self, value: impl Into<String>) -> Self {
self.after = Some(value.into());
self
}
pub fn before(mut self, value: impl Into<String>) -> Self {
self.before = Some(value.into());
self
}
pub fn limit(mut self, value: u32) -> Self {
self.limit = Some(value);
self
}
}