use serde::{Deserialize, Serialize};
use super::auth::ApiCredentials;
pub const WS_MARKET_URL: &str = "wss://ws-subscriptions-clob.polymarket.com/ws/market";
pub const WS_USER_URL: &str = "wss://ws-subscriptions-clob.polymarket.com/ws/user";
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum ChannelType {
Market,
User,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MarketSubscription {
pub assets_ids: Vec<String>,
#[serde(rename = "type")]
pub channel_type: ChannelType,
}
impl MarketSubscription {
pub fn new(assets_ids: Vec<String>) -> Self {
Self {
assets_ids,
channel_type: ChannelType::Market,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UserSubscription {
pub markets: Vec<String>,
pub auth: ApiCredentials,
#[serde(rename = "type")]
pub channel_type: ChannelType,
}
impl UserSubscription {
pub fn new(markets: Vec<String>, credentials: ApiCredentials) -> Self {
Self {
markets,
auth: credentials,
channel_type: ChannelType::User,
}
}
}