use std::collections::BTreeMap;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub struct Arg {
pub channel: String,
#[serde(rename = "instId", skip_serializing_if = "Option::is_none")]
pub inst_id: Option<String>,
#[serde(rename = "instType", skip_serializing_if = "Option::is_none")]
pub inst_type: Option<String>,
#[serde(rename = "instFamily", skip_serializing_if = "Option::is_none")]
pub inst_family: Option<String>,
#[serde(flatten, default, skip_serializing_if = "BTreeMap::is_empty")]
pub extra: BTreeMap<String, String>,
}
impl Arg {
pub fn new(channel: impl Into<String>) -> Self {
Self {
channel: channel.into(),
inst_id: None,
inst_type: None,
inst_family: None,
extra: BTreeMap::new(),
}
}
pub fn inst_id(mut self, inst_id: impl Into<String>) -> Self {
self.inst_id = Some(inst_id.into());
self
}
pub fn inst_type(mut self, inst_type: impl Into<String>) -> Self {
self.inst_type = Some(inst_type.into());
self
}
pub fn inst_family(mut self, inst_family: impl Into<String>) -> Self {
self.inst_family = Some(inst_family.into());
self
}
pub fn param(mut self, key: impl Into<String>, value: impl Into<String>) -> Self {
self.extra.insert(key.into(), value.into());
self
}
pub fn ccy(self, ccy: impl Into<String>) -> Self {
self.param("ccy", ccy)
}
pub fn sprd_id(self, sprd_id: impl Into<String>) -> Self {
self.param("sprdId", sprd_id)
}
pub fn algo_id(self, algo_id: impl Into<String>) -> Self {
self.param("algoId", algo_id)
}
pub fn grid_type(self, grid_type: impl Into<String>) -> Self {
self.param("gridType", grid_type)
}
}