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