rusftx/rest/requests/
get_markets.rs

1use crate::rest::model::market::Market;
2use crate::rest::request::{AuthenticatedRequest, Request, UnauthenticatedRequest};
3use std::borrow::Cow;
4
5#[derive(Debug, Default)]
6pub struct GetMarketsRequest {}
7
8impl Request for GetMarketsRequest {
9    type Response = Vec<Market>;
10    type Query = ();
11    type Body = ();
12
13    fn path(&self) -> Cow<str> {
14        "markets".into()
15    }
16
17    fn method(&self) -> http::Method {
18        http::Method::GET
19    }
20}
21
22impl UnauthenticatedRequest for GetMarketsRequest {}
23impl AuthenticatedRequest for GetMarketsRequest {}
24
25#[cfg(test)]
26mod tests {
27    use super::*;
28    use crate::endpoint::EndpointCom;
29    use crate::rest::RestApi;
30
31    #[tokio::test]
32    async fn test_get_markets_request() {
33        let rest_api = RestApi::<EndpointCom>::default();
34        let request = GetMarketsRequest::default();
35        let result = rest_api.send(request).await;
36        assert!(result.is_ok());
37    }
38}