Skip to main content

gateio_rs/api/spot/
get_currency.rs

1use crate::http::{Credentials, Method, request::Request};
2
3/// Request for retrieving information about a specific currency
4pub struct GetCurrency {
5    /// Currency symbol to get information for
6    pub currency: String,
7    /// API credentials for authentication (optional for public data)
8    pub credentials: Option<Credentials>,
9}
10
11impl GetCurrency {
12    /// Creates a new GetCurrency request for the specified currency
13    pub fn new(currency: &str) -> Self {
14        Self {
15            currency: currency.to_owned(),
16            credentials: None,
17        }
18    }
19
20    /// Sets the API credentials for authentication
21    pub fn credentials(mut self, creds: Credentials) -> Self {
22        self.credentials = Some(creds);
23        self
24    }
25}
26
27impl From<GetCurrency> for Request {
28    fn from(request: GetCurrency) -> Request {
29        let params = Vec::new();
30
31        Request {
32            method: Method::Get,
33            path: format!("/api/v4/spot/currencies/{}", request.currency).into(),
34            params,
35            payload: "".to_string(),
36            x_gate_exp_time: None,
37            credentials: request.credentials,
38            sign: false,
39        }
40    }
41}