Skip to main content

radion_sdk/
config.rs

1//! Shared configuration for every Radion product surface.
2
3/// Default base URL for the Radion REST API.
4pub const DEFAULT_BASE_URL: &str = "https://api.radion.app";
5
6/// Default endpoint for the Radion realtime (WebSocket) API.
7pub const DEFAULT_WS_URL: &str = "wss://api.radion.app/ws";
8
9/// Shared configuration for every Radion product surface.
10///
11/// `base_url` is reserved for forthcoming product surfaces; the realtime client
12/// uses `ws_url`.
13#[derive(Debug, Clone)]
14pub struct RadionConfig {
15    /// Radion API key, sent as the `X-API-Key` header on every request.
16    pub api_key: String,
17    /// Base URL for the REST API. Defaults to [`DEFAULT_BASE_URL`].
18    pub base_url: String,
19    /// Realtime endpoint. Defaults to [`DEFAULT_WS_URL`].
20    pub ws_url: String,
21}
22
23impl RadionConfig {
24    /// Build a config from an API key, using the default URLs.
25    pub fn new(api_key: impl Into<String>) -> Self {
26        Self {
27            api_key: api_key.into(),
28            base_url: DEFAULT_BASE_URL.to_string(),
29            ws_url: DEFAULT_WS_URL.to_string(),
30        }
31    }
32}