longport/trade/requests/
get_cash_flow.rs

1use serde::Serialize;
2use time::OffsetDateTime;
3
4use crate::{serde_utils, trade::BalanceType};
5
6/// Options for cash flow request
7#[derive(Debug, Serialize, Clone)]
8pub struct GetCashFlowOptions {
9    #[serde(rename = "start_time", with = "serde_utils::timestamp")]
10    start_at: OffsetDateTime,
11    #[serde(rename = "end_time", with = "serde_utils::timestamp")]
12    end_at: OffsetDateTime,
13    business_type: Option<BalanceType>,
14    symbol: Option<String>,
15    page: Option<usize>,
16    size: Option<usize>,
17}
18
19impl GetCashFlowOptions {
20    /// Create a new `GetCashFlowOptions`
21    #[inline]
22    pub fn new(start_at: OffsetDateTime, end_at: OffsetDateTime) -> Self {
23        Self {
24            start_at,
25            end_at,
26            business_type: None,
27            symbol: None,
28            page: None,
29            size: None,
30        }
31    }
32
33    /// Set the business type
34    #[inline]
35    #[must_use]
36    pub fn business_type(self, business_type: BalanceType) -> Self {
37        Self {
38            business_type: Some(business_type),
39            ..self
40        }
41    }
42
43    /// Set the security symbol
44    #[inline]
45    #[must_use]
46    pub fn symbol(self, symbol: impl Into<String>) -> Self {
47        Self {
48            symbol: Some(symbol.into()),
49            ..self
50        }
51    }
52
53    /// Set the page number
54    #[inline]
55    #[must_use]
56    pub fn page(self, page: usize) -> Self {
57        Self {
58            page: Some(page),
59            ..self
60        }
61    }
62
63    /// Set the page size
64    #[inline]
65    #[must_use]
66    pub fn size(self, size: usize) -> Self {
67        Self {
68            size: Some(size),
69            ..self
70        }
71    }
72}