use std::borrow::Cow;
use serde::Serialize;
#[derive(Debug, Clone, Default, Serialize)]
pub struct StakingDefiOffersRequest<'a> {
#[serde(rename = "productId", skip_serializing_if = "Option::is_none")]
product_id: Option<Cow<'a, str>>,
#[serde(rename = "protocolType", skip_serializing_if = "Option::is_none")]
protocol_type: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
ccy: Option<Cow<'a, str>>,
}
impl<'a> StakingDefiOffersRequest<'a> {
pub fn new() -> Self {
Self::default()
}
pub fn product_id(mut self, value: impl Into<Cow<'a, str>>) -> Self {
self.product_id = Some(value.into());
self
}
pub fn protocol_type(mut self, value: impl Into<Cow<'a, str>>) -> Self {
self.protocol_type = Some(value.into());
self
}
pub fn currency(mut self, value: impl Into<Cow<'a, str>>) -> Self {
self.ccy = Some(value.into());
self
}
}
#[derive(Debug, Clone, Serialize)]
pub struct StakingDefiInvestment<'a> {
ccy: Cow<'a, str>,
amt: Cow<'a, str>,
}
impl<'a> StakingDefiInvestment<'a> {
pub fn new(ccy: impl Into<Cow<'a, str>>, amt: impl Into<Cow<'a, str>>) -> Self {
Self {
ccy: ccy.into(),
amt: amt.into(),
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct StakingDefiPurchaseRequest<'a> {
#[serde(rename = "productId")]
product_id: Cow<'a, str>,
#[serde(rename = "investData")]
invest_data: Vec<StakingDefiInvestment<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
term: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
tag: Option<Cow<'a, str>>,
}
impl<'a> StakingDefiPurchaseRequest<'a> {
pub fn new(
product_id: impl Into<Cow<'a, str>>,
invest_data: Vec<StakingDefiInvestment<'a>>,
) -> Self {
Self {
product_id: product_id.into(),
invest_data,
term: None,
tag: None,
}
}
pub fn term(mut self, value: impl Into<Cow<'a, str>>) -> Self {
self.term = Some(value.into());
self
}
pub fn tag(mut self, value: impl Into<Cow<'a, str>>) -> Self {
self.tag = Some(value.into());
self
}
}
#[derive(Debug, Clone, Serialize)]
pub struct StakingDefiRedeemRequest<'a> {
#[serde(rename = "ordId")]
ord_id: Cow<'a, str>,
#[serde(rename = "protocolType")]
protocol_type: Cow<'a, str>,
#[serde(rename = "allowEarlyRedeem", skip_serializing_if = "Option::is_none")]
allow_early_redeem: Option<bool>,
}
impl<'a> StakingDefiRedeemRequest<'a> {
pub fn new(ord_id: impl Into<Cow<'a, str>>, protocol_type: impl Into<Cow<'a, str>>) -> Self {
Self {
ord_id: ord_id.into(),
protocol_type: protocol_type.into(),
allow_early_redeem: None,
}
}
pub fn allow_early_redeem(mut self, value: bool) -> Self {
self.allow_early_redeem = Some(value);
self
}
}
#[derive(Debug, Clone, Serialize)]
pub struct StakingDefiCancelRequest<'a> {
#[serde(rename = "ordId")]
ord_id: Cow<'a, str>,
#[serde(rename = "protocolType")]
protocol_type: Cow<'a, str>,
}
impl<'a> StakingDefiCancelRequest<'a> {
pub fn new(ord_id: impl Into<Cow<'a, str>>, protocol_type: impl Into<Cow<'a, str>>) -> Self {
Self {
ord_id: ord_id.into(),
protocol_type: protocol_type.into(),
}
}
}
#[derive(Debug, Clone, Default, Serialize)]
pub struct StakingDefiActiveOrdersRequest<'a> {
#[serde(rename = "productId", skip_serializing_if = "Option::is_none")]
product_id: Option<Cow<'a, str>>,
#[serde(rename = "protocolType", skip_serializing_if = "Option::is_none")]
protocol_type: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
ccy: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
state: Option<Cow<'a, str>>,
}
impl<'a> StakingDefiActiveOrdersRequest<'a> {
pub fn new() -> Self {
Self::default()
}
pub fn product_id(mut self, value: impl Into<Cow<'a, str>>) -> Self {
self.product_id = Some(value.into());
self
}
pub fn protocol_type(mut self, value: impl Into<Cow<'a, str>>) -> Self {
self.protocol_type = Some(value.into());
self
}
pub fn currency(mut self, value: impl Into<Cow<'a, str>>) -> Self {
self.ccy = Some(value.into());
self
}
pub fn state(mut self, value: impl Into<Cow<'a, str>>) -> Self {
self.state = Some(value.into());
self
}
}
#[derive(Debug, Clone, Default, Serialize)]
pub struct StakingDefiOrderHistoryRequest<'a> {
#[serde(rename = "productId", skip_serializing_if = "Option::is_none")]
product_id: Option<Cow<'a, str>>,
#[serde(rename = "protocolType", skip_serializing_if = "Option::is_none")]
protocol_type: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
ccy: 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> StakingDefiOrderHistoryRequest<'a> {
pub fn new() -> Self {
Self::default()
}
pub fn product_id(mut self, value: impl Into<Cow<'a, str>>) -> Self {
self.product_id = Some(value.into());
self
}
pub fn protocol_type(mut self, value: impl Into<Cow<'a, str>>) -> Self {
self.protocol_type = Some(value.into());
self
}
pub fn currency(mut self, value: impl Into<Cow<'a, str>>) -> Self {
self.ccy = Some(value.into());
self
}
pub fn after(mut self, value: impl Into<Cow<'a, str>>) -> Self {
self.after = Some(value.into());
self
}
pub fn before(mut self, value: impl Into<Cow<'a, str>>) -> Self {
self.before = Some(value.into());
self
}
pub fn limit(mut self, value: u32) -> Self {
self.limit = Some(value);
self
}
}