pub mod rest_api;
pub mod websocket_streams;
use crate::common::{
config::{ConfigurationRestApi, ConfigurationWebsocketStreams},
constants::{
DERIVATIVES_TRADING_OPTIONS_REST_API_PROD_URL,
DERIVATIVES_TRADING_OPTIONS_REST_API_TESTNET_URL,
DERIVATIVES_TRADING_OPTIONS_WS_STREAMS_PROD_URL,
DERIVATIVES_TRADING_OPTIONS_WS_STREAMS_TESTNET_URL,
},
utils::build_user_agent,
};
pub struct DerivativesTradingOptionsRestApi {}
impl DerivativesTradingOptionsRestApi {
#[must_use]
pub fn from_config(mut config: ConfigurationRestApi) -> rest_api::RestApi {
config.user_agent = build_user_agent("derivatives-trading-options");
if config.base_path.is_none() {
config.base_path = Some(DERIVATIVES_TRADING_OPTIONS_REST_API_PROD_URL.to_string());
}
rest_api::RestApi::new(config)
}
#[must_use]
pub fn production(mut config: ConfigurationRestApi) -> rest_api::RestApi {
config.base_path = Some(DERIVATIVES_TRADING_OPTIONS_REST_API_PROD_URL.to_string());
DerivativesTradingOptionsRestApi::from_config(config)
}
#[must_use]
pub fn testnet(mut config: ConfigurationRestApi) -> rest_api::RestApi {
config.base_path = Some(DERIVATIVES_TRADING_OPTIONS_REST_API_TESTNET_URL.to_string());
DerivativesTradingOptionsRestApi::from_config(config)
}
}
pub struct DerivativesTradingOptionsWsStreams {}
impl DerivativesTradingOptionsWsStreams {
#[must_use]
pub fn from_config(
mut config: ConfigurationWebsocketStreams,
) -> websocket_streams::WebsocketStreamsHandle {
config.user_agent = build_user_agent("derivatives-trading-options");
if config.ws_url.is_none() {
config.ws_url = Some(DERIVATIVES_TRADING_OPTIONS_WS_STREAMS_PROD_URL.to_string());
}
websocket_streams::WebsocketStreamsHandle::new(config)
}
#[must_use]
pub fn production(
mut config: ConfigurationWebsocketStreams,
) -> websocket_streams::WebsocketStreamsHandle {
config.ws_url = Some(DERIVATIVES_TRADING_OPTIONS_WS_STREAMS_PROD_URL.to_string());
DerivativesTradingOptionsWsStreams::from_config(config)
}
#[must_use]
pub fn testnet(
mut config: ConfigurationWebsocketStreams,
) -> websocket_streams::WebsocketStreamsHandle {
config.ws_url = Some(DERIVATIVES_TRADING_OPTIONS_WS_STREAMS_TESTNET_URL.to_string());
DerivativesTradingOptionsWsStreams::from_config(config)
}
}