Skip to main content

gateio_rs/api/spot/
get_currency_pair.rs

1use crate::http::{Credentials, Method, request::Request};
2
3/// Request for retrieving information about a specific currency pair
4pub struct GetCurrencyPair {
5    /// Currency pair to get information for (e.g., "BTC_USDT")
6    pub currency_pair: String,
7    /// API credentials for authentication (optional for public data)
8    pub credentials: Option<Credentials>,
9}
10
11impl GetCurrencyPair {
12    /// Creates a new GetCurrencyPair request for the specified pair
13    pub fn new(currency_pair: &str) -> Self {
14        Self {
15            currency_pair: currency_pair.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<GetCurrencyPair> for Request {
28    fn from(request: GetCurrencyPair) -> Request {
29        let params = Vec::new();
30
31        Request {
32            method: Method::Get,
33            path: format!("/api/v4/spot/currency_pairs/{}", request.currency_pair).into(),
34            params,
35            payload: "".to_string(),
36            x_gate_exp_time: None,
37            credentials: request.credentials,
38            sign: false,
39        }
40    }
41}