1use crate::models::{
2 Board, Candle, CandleBorder, Engine, Index, IndexAnalytics, Market, OrderbookLevel, SecStat,
3 Security, SecurityBoard, SecuritySnapshot, Trade, Turnover,
4};
5#[cfg(feature = "news")]
6use crate::models::{Event, SiteNews};
7#[cfg(feature = "history")]
8use crate::models::{HistoryDates, HistoryRecord};
9
10use super::MoexError;
11use super::constants::{
12 BOARDS_ENDPOINT_TEMPLATE, CANDLEBORDERS_ENDPOINT_TEMPLATE, CANDLES_ENDPOINT_TEMPLATE,
13 INDEX_ANALYTICS_ENDPOINT_TEMPLATE, MARKETS_ENDPOINT_TEMPLATE, ORDERBOOK_ENDPOINT_TEMPLATE,
14 SECSTATS_ENDPOINT_TEMPLATE, SECURITIES_ENDPOINT_TEMPLATE, SECURITY_BOARDS_ENDPOINT_TEMPLATE,
15 TRADES_ENDPOINT_TEMPLATE, TURNOVERS_ENDPOINT,
16};
17#[cfg(feature = "news")]
18use super::constants::{EVENTS_ENDPOINT, SITENEWS_ENDPOINT};
19#[cfg(feature = "history")]
20use super::constants::{HISTORY_DATES_ENDPOINT_TEMPLATE, HISTORY_ENDPOINT_TEMPLATE};
21use super::payload::{
22 decode_board_security_snapshots_json_with_endpoint, decode_boards_json_with_endpoint,
23 decode_candle_borders_json_with_endpoint, decode_candles_json_with_endpoint,
24 decode_engines_json_payload, decode_index_analytics_json_with_endpoint,
25 decode_indexes_json_payload, decode_markets_json_with_endpoint,
26 decode_orderbook_json_with_endpoint, decode_raw_table_rows_json_with_endpoint,
27 decode_raw_table_view_json_with_endpoint, decode_raw_tables_json_with_endpoint,
28 decode_secstats_json_with_endpoint, decode_securities_json_with_endpoint,
29 decode_security_boards_json_with_endpoint, decode_trades_json_with_endpoint,
30 decode_turnovers_json_with_endpoint,
31};
32#[cfg(feature = "news")]
33use super::payload::{decode_events_json_with_endpoint, decode_sitenews_json_with_endpoint};
34#[cfg(feature = "history")]
35use super::payload::{decode_history_dates_json_with_endpoint, decode_history_json_with_endpoint};
36
37pub use super::payload::{RawTableView, RawTables};
38
39pub fn indexes_json(payload: &str) -> Result<Vec<Index>, MoexError> {
41 decode_indexes_json_payload(payload)
42}
43
44pub fn engines_json(payload: &str) -> Result<Vec<Engine>, MoexError> {
46 decode_engines_json_payload(payload)
47}
48
49pub fn markets_json(payload: &str) -> Result<Vec<Market>, MoexError> {
51 decode_markets_json_with_endpoint(payload, MARKETS_ENDPOINT_TEMPLATE)
52}
53
54pub fn boards_json(payload: &str) -> Result<Vec<Board>, MoexError> {
56 decode_boards_json_with_endpoint(payload, BOARDS_ENDPOINT_TEMPLATE)
57}
58
59pub fn security_boards_json(payload: &str) -> Result<Vec<SecurityBoard>, MoexError> {
61 decode_security_boards_json_with_endpoint(payload, SECURITY_BOARDS_ENDPOINT_TEMPLATE)
62}
63
64pub fn securities_json(payload: &str) -> Result<Vec<Security>, MoexError> {
66 decode_securities_json_with_endpoint(payload, SECURITIES_ENDPOINT_TEMPLATE)
67}
68
69pub fn board_security_snapshots_json(payload: &str) -> Result<Vec<SecuritySnapshot>, MoexError> {
71 decode_board_security_snapshots_json_with_endpoint(payload, SECURITIES_ENDPOINT_TEMPLATE)
72}
73
74pub fn orderbook_json(payload: &str) -> Result<Vec<OrderbookLevel>, MoexError> {
76 decode_orderbook_json_with_endpoint(payload, ORDERBOOK_ENDPOINT_TEMPLATE)
77}
78
79pub fn candle_borders_json(payload: &str) -> Result<Vec<CandleBorder>, MoexError> {
81 decode_candle_borders_json_with_endpoint(payload, CANDLEBORDERS_ENDPOINT_TEMPLATE)
82}
83
84pub fn candles_json(payload: &str) -> Result<Vec<Candle>, MoexError> {
86 decode_candles_json_with_endpoint(payload, CANDLES_ENDPOINT_TEMPLATE)
87}
88
89pub fn trades_json(payload: &str) -> Result<Vec<Trade>, MoexError> {
91 decode_trades_json_with_endpoint(payload, TRADES_ENDPOINT_TEMPLATE)
92}
93
94pub fn index_analytics_json(payload: &str) -> Result<Vec<IndexAnalytics>, MoexError> {
96 decode_index_analytics_json_with_endpoint(payload, INDEX_ANALYTICS_ENDPOINT_TEMPLATE)
97}
98
99pub fn turnovers_json(payload: &str) -> Result<Vec<Turnover>, MoexError> {
101 decode_turnovers_json_with_endpoint(payload, TURNOVERS_ENDPOINT)
102}
103
104pub fn secstats_json(payload: &str) -> Result<Vec<SecStat>, MoexError> {
106 decode_secstats_json_with_endpoint(payload, SECSTATS_ENDPOINT_TEMPLATE)
107}
108
109#[cfg(feature = "history")]
110pub fn history_dates_json(payload: &str) -> Result<Vec<HistoryDates>, MoexError> {
112 decode_history_dates_json_with_endpoint(payload, HISTORY_DATES_ENDPOINT_TEMPLATE)
113}
114
115#[cfg(feature = "history")]
116pub fn history_json(payload: &str) -> Result<Vec<HistoryRecord>, MoexError> {
118 decode_history_json_with_endpoint(payload, HISTORY_ENDPOINT_TEMPLATE)
119}
120
121#[cfg(feature = "news")]
122pub fn sitenews_json(payload: &str) -> Result<Vec<SiteNews>, MoexError> {
124 decode_sitenews_json_with_endpoint(payload, SITENEWS_ENDPOINT)
125}
126
127#[cfg(feature = "news")]
128pub fn events_json(payload: &str) -> Result<Vec<Event>, MoexError> {
130 decode_events_json_with_endpoint(payload, EVENTS_ENDPOINT)
131}
132
133pub fn raw_table_rows_json<T>(
138 payload: &str,
139 endpoint: &str,
140 table: &str,
141) -> Result<Vec<T>, MoexError>
142where
143 T: serde::de::DeserializeOwned,
144{
145 decode_raw_table_rows_json_with_endpoint(payload, endpoint, table)
146}
147
148pub fn raw_table_view_json<'a>(
152 payload: &'a str,
153 endpoint: &str,
154 table: &str,
155) -> Result<RawTableView<'a>, MoexError> {
156 decode_raw_table_view_json_with_endpoint(payload, endpoint, table)
157}
158
159pub fn raw_tables_json(payload: &str, endpoint: &str) -> Result<RawTables, MoexError> {
165 decode_raw_tables_json_with_endpoint(payload, endpoint)
166}