Skip to main content

gateio_rs/api/spot/
get_fee.rs

1use crate::http::{Credentials, Method, request::Request};
2
3/// Request for retrieving trading fees for spot trading
4pub struct GetFee {
5    /// Optional currency pair to get specific trading fees for
6    pub currency_pair: Option<String>,
7    /// API credentials for authentication
8    pub credentials: Option<Credentials>,
9}
10
11impl GetFee {
12    /// Creates a new GetFee request
13    pub fn new() -> Self {
14        Self {
15            currency_pair: None,
16            credentials: None,
17        }
18    }
19
20    /// Sets the currency pair to get specific fees for
21    pub fn currency_pair(mut self, currency_pair: &str) -> Self {
22        self.currency_pair = Some(currency_pair.into());
23        self
24    }
25
26    /// Sets the API credentials for authentication
27    pub fn credentials(mut self, creds: Credentials) -> Self {
28        self.credentials = Some(creds);
29        self
30    }
31}
32
33impl From<GetFee> for Request {
34    fn from(request: GetFee) -> Request {
35        let mut params = Vec::new();
36        if let Some(currency_pair) = request.currency_pair {
37            params.push(("currency_pair".into(), currency_pair));
38        }
39
40        Request {
41            method: Method::Get,
42            path: "/api/v4/spot/fee".into(),
43            params,
44            payload: "".to_string(),
45            x_gate_exp_time: None,
46            credentials: request.credentials,
47            sign: true,
48        }
49    }
50}