polyio/api/
ticker_types.rs

1// Copyright (C) 2020-2022 Daniel Mueller <deso@posteo.net>
2// SPDX-License-Identifier: GPL-3.0-or-later
3
4use std::collections::BTreeMap;
5
6use serde::Deserialize;
7
8use crate::api::response::Response;
9use crate::Str;
10
11
12/// A struct representing the ticker types.
13///
14/// Please note that not all fields available in a request are
15/// represented here.
16#[derive(Clone, Debug, Deserialize, PartialEq)]
17pub struct TickerTypes {
18  /// A mapping from ticker types to descriptions.
19  #[serde(rename = "types")]
20  pub types: BTreeMap<String, String>,
21  /// A mapping from index types to descriptions.
22  #[serde(rename = "indexTypes")]
23  pub index_types: BTreeMap<String, String>,
24}
25
26Endpoint! {
27  /// The representation of a GET request to the `/v2/reference/types`
28  /// endpoint.
29  pub Get(()),
30  Ok => Response<TickerTypes>, [
31    /// The ticker types were retrieved successfully.
32    /* 200 */ OK,
33  ],
34  Err => GetError, []
35
36  fn path(_input: &Self::Input) -> Str {
37    "/v2/reference/types".into()
38  }
39}
40
41
42#[cfg(not(target_arch = "wasm32"))]
43#[cfg(test)]
44mod tests {
45  use super::*;
46
47  use test_log::test;
48
49  use crate::Client;
50
51  #[test(tokio::test)]
52  async fn request_ticker_types() {
53    let client = Client::from_env().unwrap();
54    let types = client.issue::<Get>(()).await.unwrap();
55
56    println!("{:?}", types);
57  }
58}