Skip to main content

slack_rs/api/
envelope.rs

1//! Unified output envelope for all commands
2//!
3//! Provides a consistent output structure with response and metadata
4
5use serde::{Deserialize, Serialize};
6use serde_json::Value;
7
8/// Unified command response with envelope
9#[derive(Debug, Serialize, Deserialize)]
10pub struct CommandResponse {
11    /// Original API response
12    pub response: Value,
13
14    /// Execution metadata
15    pub meta: CommandMeta,
16}
17
18/// Command execution metadata
19#[derive(Debug, Serialize, Deserialize)]
20pub struct CommandMeta {
21    pub profile_name: Option<String>,
22    pub team_id: String,
23    pub user_id: String,
24    pub method: String,
25    pub command: String,
26}
27
28impl CommandResponse {
29    /// Create a new command response with metadata
30    pub fn new(
31        response: Value,
32        profile_name: Option<String>,
33        team_id: String,
34        user_id: String,
35        method: String,
36        command: String,
37    ) -> Self {
38        Self {
39            response,
40            meta: CommandMeta {
41                profile_name,
42                team_id,
43                user_id,
44                method,
45                command,
46            },
47        }
48    }
49}