mod client;
mod error;
mod session;

use std::collections::BTreeMap;

use serde::{Deserialize, Serialize};
use serde_json::Value;

pub use client::WebsocketAdapter;
pub use error::WebsocketAdapterError;
pub use session::{HeartbeatPolicy, ReconnectPolicy};

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Default)]
pub struct WebsocketWindowRequest {
    #[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
    pub headers: BTreeMap<String, String>,
    pub window_duration_ms: u64,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub max_items: Option<u32>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub heartbeat_interval_ms: Option<u64>,
    #[serde(default)]
    pub reconnect_max_attempts: u32,
    #[serde(default)]
    pub reconnect_backoff_ms: u64,
}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct WebsocketWindowResponse {
    pub status_code: u16,
    #[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
    pub headers: BTreeMap<String, String>,
    pub body: Value,
}
