reddit_insights/
types.rs

1//! Type definitions for the Reddit Insights SDK
2
3use serde::{Deserialize, Serialize};
4
5/// A single search result
6#[derive(Debug, Clone, Deserialize, Serialize)]
7pub struct SearchResult {
8    pub id: String,
9    pub title: String,
10    pub content: String,
11    pub subreddit: String,
12    pub upvotes: i32,
13    pub comments: i32,
14    pub created: String,
15    #[serde(skip_serializing_if = "Option::is_none")]
16    pub relevance: Option<f64>,
17    #[serde(skip_serializing_if = "Option::is_none")]
18    pub similarity_score: Option<f64>,
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub sentiment: Option<String>,
21    pub url: String,
22}
23
24/// Response from semantic search
25#[derive(Debug, Clone, Deserialize)]
26pub struct SemanticSearchResponse {
27    pub success: bool,
28    pub data: Option<SemanticSearchData>,
29    pub error: Option<String>,
30}
31
32#[derive(Debug, Clone, Deserialize)]
33pub struct SemanticSearchData {
34    pub query: String,
35    pub results: Vec<SearchResult>,
36    pub total: i32,
37    pub processing_time_ms: i32,
38    pub ai_summary: Option<String>,
39}
40
41/// Response from vector search
42#[derive(Debug, Clone, Deserialize)]
43pub struct VectorSearchResponse {
44    pub success: bool,
45    pub data: Option<VectorSearchData>,
46    pub error: Option<String>,
47}
48
49#[derive(Debug, Clone, Deserialize)]
50pub struct VectorSearchData {
51    pub query: String,
52    pub results: Vec<SearchResult>,
53    pub total: i32,
54    pub processing_time_ms: i32,
55}
56
57/// A trending topic
58#[derive(Debug, Clone, Deserialize)]
59pub struct TrendTopic {
60    pub id: String,
61    pub topic: String,
62    pub post_count: i32,
63    pub total_upvotes: i32,
64    pub total_comments: i32,
65    pub avg_sentiment: f64,
66    pub top_subreddits: Vec<String>,
67    pub trending_keywords: Vec<String>,
68    pub sample_posts: Vec<SamplePost>,
69    pub trend_score: f64,
70    pub growth_rate: f64,
71}
72
73#[derive(Debug, Clone, Deserialize)]
74pub struct SamplePost {
75    pub id: String,
76    pub title: String,
77    pub subreddit: String,
78    pub upvotes: i32,
79    pub comments: i32,
80    pub created: String,
81}
82
83/// Response from trends endpoint
84#[derive(Debug, Clone, Deserialize)]
85pub struct TrendsResponse {
86    pub success: bool,
87    pub data: Option<TrendsData>,
88    pub error: Option<String>,
89}
90
91#[derive(Debug, Clone, Deserialize)]
92pub struct TrendsData {
93    pub trends: Vec<TrendTopic>,
94    pub total: i32,
95    pub date_range: DateRange,
96    pub processing_time_ms: i32,
97}
98
99#[derive(Debug, Clone, Deserialize)]
100pub struct DateRange {
101    pub start: String,
102    pub end: String,
103}
104
105/// A monitoring sonar
106#[derive(Debug, Clone, Deserialize)]
107#[serde(rename_all = "camelCase")]
108pub struct Sonar {
109    pub id: String,
110    pub name: String,
111    pub query: String,
112    pub description: Option<String>,
113    pub enabled: bool,
114    pub schedule: String,
115    pub last_executed_at: Option<String>,
116    pub next_execution_at: Option<String>,
117    pub created_at: String,
118}
119
120/// Response from list sonars endpoint
121#[derive(Debug, Clone, Deserialize)]
122pub struct SonarsResponse {
123    pub success: bool,
124    pub data: Option<SonarsData>,
125    pub error: Option<String>,
126}
127
128#[derive(Debug, Clone, Deserialize)]
129pub struct SonarsData {
130    pub sonars: Vec<Sonar>,
131}
132
133/// Options for creating a sonar
134#[derive(Debug, Clone, Serialize)]
135#[serde(rename_all = "camelCase")]
136pub struct CreateSonarOptions {
137    pub name: String,
138    pub query: String,
139    #[serde(skip_serializing_if = "Option::is_none")]
140    pub description: Option<String>,
141    #[serde(skip_serializing_if = "Option::is_none")]
142    pub schedule: Option<String>,
143    #[serde(skip_serializing_if = "Option::is_none")]
144    pub triggers: Option<serde_json::Value>,
145    #[serde(skip_serializing_if = "Option::is_none")]
146    pub notify_email: Option<bool>,
147    #[serde(skip_serializing_if = "Option::is_none")]
148    pub notify_slack: Option<bool>,
149    #[serde(skip_serializing_if = "Option::is_none")]
150    pub slack_webhook: Option<String>,
151}
152
153/// Response from create sonar endpoint
154#[derive(Debug, Clone, Deserialize)]
155pub struct CreateSonarResponse {
156    pub success: bool,
157    pub data: Option<CreateSonarData>,
158    pub error: Option<String>,
159}
160
161#[derive(Debug, Clone, Deserialize)]
162pub struct CreateSonarData {
163    pub sonar: Sonar,
164}
165