Skip to main content

nautilus_rs/resources/relay/
types.rs

1/// A webhook message returned by the Relay API.
2#[derive(Debug, Clone, serde::Deserialize)]
3pub struct Message {
4    /// Unique message identifier.
5    pub id: String,
6    /// The event type that was dispatched (e.g. `"order.placed"`).
7    pub event_type: String,
8    /// Delivery status (`"pending"`, `"delivered"`, `"failed"`, …).
9    pub status: String,
10    /// ISO 8601 timestamp of when the message was created.
11    pub timestamp: String,
12}
13
14/// Parameters for [`MessagesClient::send`](super::MessagesClient::send).
15///
16/// # Example
17///
18/// ```no_run
19/// use nautilus_rs::{Relay, SendMessageParams};
20/// use serde_json::json;
21///
22/// # async fn run() -> Result<(), nautilus_rs::Error> {
23/// let relay = Relay::new("vrn_relay_live_sk_…");
24/// let msg = relay.messages().send(SendMessageParams {
25///     event_type: "order.placed".into(),
26///     payload: json!({ "order_id": "ord_123", "total": 49.99 }),
27///     idempotency_key: Some("ord_123-placed".into()),
28///     channels: Some(vec!["primary".into()]),
29/// }).await?;
30/// # Ok(())
31/// # }
32/// ```
33#[derive(Debug, Clone, Default, serde::Serialize)]
34pub struct SendMessageParams {
35    /// The event type to dispatch (e.g. `"order.placed"`).
36    pub event_type: String,
37    /// Arbitrary JSON payload delivered to all subscribed endpoints.
38    pub payload: serde_json::Value,
39    /// Optional idempotency key — reusing the same key within the deduplication
40    /// window returns the original message instead of creating a new one.
41    #[serde(skip_serializing_if = "Option::is_none")]
42    pub idempotency_key: Option<String>,
43    /// Restrict delivery to the named channels. `None` delivers to all channels.
44    #[serde(skip_serializing_if = "Option::is_none")]
45    pub channels: Option<Vec<String>>,
46}
47
48/// Parameters for [`MessagesClient::list`](super::MessagesClient::list).
49#[derive(Debug, Clone, Default, serde::Serialize)]
50pub struct ListMessagesParams {
51    /// Maximum number of messages to return (server default applies when
52    /// `None`).
53    #[serde(skip_serializing_if = "Option::is_none")]
54    pub limit: Option<u32>,
55    /// Pagination cursor from the previous page's
56    /// [`next_cursor`](crate::Paginated::next_cursor).
57    #[serde(skip_serializing_if = "Option::is_none")]
58    pub cursor: Option<String>,
59    /// Filter results to a specific event type.
60    #[serde(skip_serializing_if = "Option::is_none")]
61    pub event_type: Option<String>,
62}