rust_okx/api/finance/requests/
common.rs1use std::borrow::Cow;
2
3use serde::Serialize;
4
5#[derive(Debug, Clone, Default, Serialize)]
7pub struct CurrencyRequest<'a> {
8 #[serde(skip_serializing_if = "Option::is_none")]
9 ccy: Option<Cow<'a, str>>,
10}
11
12impl<'a> CurrencyRequest<'a> {
13 pub fn new() -> Self {
15 Self::default()
16 }
17
18 pub fn currency(mut self, ccy: impl Into<Cow<'a, str>>) -> Self {
20 self.ccy = Some(ccy.into());
21 self
22 }
23}
24
25#[derive(Debug, Clone, Serialize)]
27pub struct SetLendingRateRequest<'a> {
28 ccy: Cow<'a, str>,
29 rate: Cow<'a, str>,
30}
31
32impl<'a> SetLendingRateRequest<'a> {
33 pub fn new(ccy: impl Into<Cow<'a, str>>, rate: impl Into<Cow<'a, str>>) -> Self {
35 Self {
36 ccy: ccy.into(),
37 rate: rate.into(),
38 }
39 }
40}
41
42#[derive(Debug, Clone, Serialize)]
44pub struct AmountRequest<'a> {
45 amt: Cow<'a, str>,
46}
47
48impl<'a> AmountRequest<'a> {
49 pub fn new(amt: impl Into<Cow<'a, str>>) -> Self {
51 Self { amt: amt.into() }
52 }
53}
54
55#[derive(Debug, Clone, Serialize)]
57#[serde(rename_all = "camelCase")]
58pub struct CancelRedeemRequest<'a> {
59 ord_id: Cow<'a, str>,
60}
61
62impl<'a> CancelRedeemRequest<'a> {
63 pub fn new(ord_id: impl Into<Cow<'a, str>>) -> Self {
65 Self {
66 ord_id: ord_id.into(),
67 }
68 }
69}
70
71#[derive(Debug, Clone, Serialize)]
73pub struct ApyHistoryRequest<'a> {
74 days: Cow<'a, str>,
75}
76
77impl<'a> ApyHistoryRequest<'a> {
78 pub fn new(days: impl Into<Cow<'a, str>>) -> Self {
80 Self { days: days.into() }
81 }
82}
83
84#[derive(Debug, Clone, Default, Serialize)]
86pub struct FinanceHistoryRequest<'a> {
87 #[serde(skip_serializing_if = "Option::is_none")]
88 ccy: Option<Cow<'a, str>>,
89 #[serde(skip_serializing_if = "Option::is_none")]
90 after: Option<Cow<'a, str>>,
91 #[serde(skip_serializing_if = "Option::is_none")]
92 before: Option<Cow<'a, str>>,
93 #[serde(skip_serializing_if = "Option::is_none")]
94 limit: Option<u32>,
95}
96
97impl<'a> FinanceHistoryRequest<'a> {
98 pub fn new() -> Self {
100 Self::default()
101 }
102
103 pub fn currency(mut self, ccy: impl Into<Cow<'a, str>>) -> Self {
105 self.ccy = Some(ccy.into());
106 self
107 }
108
109 pub fn after(mut self, after: impl Into<Cow<'a, str>>) -> Self {
111 self.after = Some(after.into());
112 self
113 }
114
115 pub fn before(mut self, before: impl Into<Cow<'a, str>>) -> Self {
117 self.before = Some(before.into());
118 self
119 }
120
121 pub fn limit(mut self, limit: u32) -> Self {
123 self.limit = Some(limit);
124 self
125 }
126}