rust_okx/api/account/requests/
loans.rs1use std::borrow::Cow;
2
3use serde::Serialize;
4
5#[derive(Debug, Clone, Serialize)]
7pub struct SpotManualBorrowRepayRequest<'a> {
8 ccy: Cow<'a, str>,
9 side: Cow<'a, str>,
10 amt: Cow<'a, str>,
11}
12
13impl<'a> SpotManualBorrowRepayRequest<'a> {
14 pub fn new(
16 ccy: impl Into<Cow<'a, str>>,
17 side: impl Into<Cow<'a, str>>,
18 amt: impl Into<Cow<'a, str>>,
19 ) -> Self {
20 Self {
21 ccy: ccy.into(),
22 side: side.into(),
23 amt: amt.into(),
24 }
25 }
26}
27
28#[derive(Debug, Clone, Serialize)]
30pub struct SetAutoRepayRequest {
31 #[serde(rename = "autoRepay")]
32 auto_repay: bool,
33}
34
35impl SetAutoRepayRequest {
36 pub fn new(auto_repay: bool) -> Self {
38 Self { auto_repay }
39 }
40}
41
42#[derive(Debug, Clone, Default, Serialize)]
44pub struct SpotBorrowRepayHistoryRequest<'a> {
45 #[serde(skip_serializing_if = "Option::is_none")]
46 ccy: Option<Cow<'a, str>>,
47 #[serde(rename = "type", skip_serializing_if = "Option::is_none")]
48 event_type: Option<Cow<'a, str>>,
49 #[serde(skip_serializing_if = "Option::is_none")]
50 after: Option<Cow<'a, str>>,
51 #[serde(skip_serializing_if = "Option::is_none")]
52 before: Option<Cow<'a, str>>,
53 #[serde(skip_serializing_if = "Option::is_none")]
54 limit: Option<u32>,
55}
56
57impl<'a> SpotBorrowRepayHistoryRequest<'a> {
58 pub fn new() -> Self {
60 Self::default()
61 }
62
63 pub fn currency(mut self, value: impl Into<Cow<'a, str>>) -> Self {
65 self.ccy = Some(value.into());
66 self
67 }
68
69 pub fn event_type(mut self, value: impl Into<Cow<'a, str>>) -> Self {
71 self.event_type = Some(value.into());
72 self
73 }
74
75 pub fn after(mut self, value: impl Into<Cow<'a, str>>) -> Self {
77 self.after = Some(value.into());
78 self
79 }
80
81 pub fn before(mut self, value: impl Into<Cow<'a, str>>) -> Self {
83 self.before = Some(value.into());
84 self
85 }
86
87 pub fn limit(mut self, value: u32) -> Self {
89 self.limit = Some(value);
90 self
91 }
92}
93
94#[derive(Debug, Clone, Serialize)]
96pub struct SetAutoEarnRequest<'a> {
97 #[serde(rename = "earnType")]
98 earn_type: Cow<'a, str>,
99 ccy: Cow<'a, str>,
100 action: Cow<'a, str>,
101}
102
103impl<'a> SetAutoEarnRequest<'a> {
104 pub fn new(
109 earn_type: impl Into<Cow<'a, str>>,
110 ccy: impl Into<Cow<'a, str>>,
111 action: impl Into<Cow<'a, str>>,
112 ) -> Self {
113 Self {
114 earn_type: earn_type.into(),
115 ccy: ccy.into(),
116 action: action.into(),
117 }
118 }
119}