Skip to main content

scoopit_api/
types.rs

1//! The types returned by the Scoop.it API
2use std::collections::{BTreeSet, HashMap};
3
4use serde::{Deserialize, Serialize};
5use url::Url;
6
7#[derive(Debug, Serialize, Deserialize, Clone)]
8#[serde(rename_all = "camelCase")]
9pub struct User {
10    pub id: u64,
11    pub name: String,
12    pub short_name: String,
13    pub url: String,
14    pub bio: Option<String>,
15    pub small_avatar_url: String,
16    pub medium_avatar_url: String,
17    pub avatar_url: String,
18    pub large_avatar_url: String,
19    pub curated_topics: Option<Vec<Topic>>,
20    pub followed_topics: Option<Vec<Topic>>,
21    pub premium_features: Option<BTreeSet<String>>,
22}
23
24#[derive(Debug, Serialize, Deserialize, Clone)]
25#[serde(rename_all = "camelCase")]
26pub struct Topic {
27    pub id: u64,
28
29    pub small_image_url: String,
30    pub medium_image_url: String,
31    pub image_url: String,
32    pub large_image_url: String,
33    pub description: Option<String>,
34    pub name: String,
35    pub short_name: String,
36    pub url: String,
37    pub lang: String,
38    pub curated_post_count: u64,
39    pub creator: Option<Box<User>>,
40    pub pinned_post: Option<Post>,
41    pub curated_posts: Option<Vec<Post>>,
42    pub tags: Option<Vec<TopicTag>>,
43    pub stats: Option<Stats>,
44    pub is_private: bool,
45}
46#[derive(Debug, Serialize, Deserialize, Clone)]
47#[serde(rename_all = "camelCase")]
48pub struct TopicTag {
49    pub tag: String,
50    pub post_count: u32,
51}
52#[derive(Debug, Serialize, Deserialize, Clone)]
53#[serde(rename_all = "camelCase")]
54pub struct Stats {
55    pub uv: i32,
56    pub uvp: i32,
57    pub v: i32,
58    pub vp: i32,
59}
60#[derive(Debug, Serialize, Deserialize, Clone)]
61#[serde(rename_all = "camelCase")]
62pub struct Post {
63    pub id: i64,
64    pub content: String,
65    pub html_content: String,
66    pub html_fragment: Option<String>,
67    pub insight: Option<String>,
68    pub html_insight: Option<String>,
69    pub title: String,
70    pub thanks_count: u32,
71    pub reactions_count: u32,
72    pub url: Option<String>,
73    pub scoop_url: String,
74    pub scoop_short_url: String,
75    pub small_image_url: Option<String>,
76    pub medium_image_url: Option<String>,
77    pub image_url: Option<String>,
78    pub large_image_url: Option<String>,
79    pub image_width: Option<u32>,
80    pub image_height: Option<u32>,
81    pub image_size: Option<String>,
82    pub image_position: Option<String>,
83    pub tags: Option<Vec<String>>,
84    pub comments_count: u32,
85    pub page_views: Option<u32>,
86    pub page_clicks: Option<u32>,
87    pub author: Option<User>,
88    pub is_user_suggestion: bool,
89    pub suggested_by: Option<User>,
90    pub twitter_author: Option<String>,
91    pub publication_date: Option<i64>,
92    pub curation_date: i64,
93    pub topic_id: u64,
94    pub topic: Option<Box<Topic>>,
95    // note that this may change in the future to an opaque json object
96    pub metadata: Option<HashMap<String, String>>,
97}
98#[derive(Debug, Clone)]
99pub struct SearchResults {
100    pub users: Option<Vec<User>>,
101    pub topics: Option<Vec<Topic>>,
102    pub posts: Option<Vec<Post>>,
103    pub total_found: i32,
104}
105
106#[derive(Debug, Serialize, Deserialize, Clone)]
107#[serde(rename_all = "camelCase")]
108pub struct RecipientsList {
109    pub id: i64,
110    pub name: String,
111    pub emails: Vec<String>,
112}
113
114#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
115#[serde(rename_all = "snake_case")]
116pub enum SuggestionEngineType {
117    ResearchContent,
118    ContentMonitoring,
119    Topic,
120}
121
122#[derive(Serialize, Deserialize, Debug, Clone)]
123pub struct SuggestionEngine {
124    pub id: i64,
125    pub r#type: SuggestionEngineType,
126    pub name: String,
127    pub saved_searches: Option<Vec<SuggestionEngineSavedSearch>>,
128}
129
130#[derive(Serialize, Deserialize, Debug, Clone)]
131pub struct SuggestionEngineSavedSearch {
132    id: i64,
133    name: String,
134}
135
136#[derive(Serialize, Deserialize, Debug, Clone)]
137#[serde(rename_all = "snake_case", tag = "type")]
138pub enum SourceTypeData {
139    #[serde(rename_all = "camelCase")]
140    AdvancedSearch {
141        query: String,
142    },
143    #[serde(rename_all = "camelCase")]
144    Webpage {
145        webpage_url: Url,
146    },
147    #[serde(rename_all = "camelCase")]
148    Rss {
149        rss_url: Url,
150    },
151    #[serde(rename_all = "camelCase")]
152    TwitterSearch {
153        twitter_search_query: String,
154    },
155    #[serde(rename_all = "camelCase")]
156    TwitterList {
157        twitter_list_name: String,
158        twitter_list_owner: String,
159    },
160    #[serde(rename_all = "camelCase")]
161    TwitterFollowUser {
162        twitter_user: String,
163    },
164    /// Search is encoded in the url of the source (this seems to be a scoop.it export bug)
165    YoutubeSearch,
166    /// url of the source is the facebook page
167    FacebookPage,
168    ScoopitUser,
169    /// (topic)
170    ScoopitTheme,
171}
172
173#[derive(Serialize, Deserialize, Debug, Clone)]
174#[serde(rename_all = "camelCase")]
175pub struct Source {
176    pub id: i64,
177    pub name: String,
178    pub description: String,
179    pub icon_url: Url,
180    /// in case of ScoopitUser & ScoopitTheme, the url is a relative url to https://www.scoop.it,
181    /// so we cannot enforce an Option<Url> here
182    pub url: Option<String>,
183    #[serde(flatten)]
184    pub source_type_data: SourceTypeData,
185}
186
187#[derive(Serialize, Deserialize, Debug, Clone)]
188#[serde(rename_all = "camelCase")]
189pub struct TopicGroup {
190    pub id: i64,
191    pub name: String,
192    pub url_name: String,
193    pub user_editable: bool,
194    pub topics: Vec<Topic>,
195}