1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Serialize, Deserialize)]
4pub struct User {
5 pub id: String,
6 pub username: String,
7 pub full_name: Option<String>,
8 pub biography: Option<String>,
9 pub profile_pic_url: Option<String>,
10 pub is_private: bool,
11 pub is_verified: bool,
12 pub follower_count: u64,
13 pub following_count: u64,
14 pub media_count: u64,
15 pub external_url: Option<String>,
16 pub business_email: Option<String>,
17 pub business_phone: Option<String>,
18 pub category: Option<String>,
19}
20
21#[derive(Debug, Clone, Serialize, Deserialize)]
22pub struct Media {
23 pub id: String,
24 pub shortcode: String,
25 pub media_type: MediaType,
26 pub caption: Option<String>,
27 pub timestamp: i64,
28 pub like_count: u64,
29 pub comment_count: u64,
30 pub view_count: Option<u64>,
31 pub play_count: Option<u64>,
32 pub display_url: String,
33 pub video_url: Option<String>,
34 pub owner: MediaOwner,
35 pub is_video: bool,
36 pub tagged_users: Vec<TaggedUser>,
37 pub location: Option<Location>,
38}
39
40#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
41#[serde(rename_all = "snake_case")]
42pub enum MediaType {
43 Image,
44 Video,
45 Reel,
46 Carousel,
47 Story,
48}
49
50#[derive(Debug, Clone, Serialize, Deserialize)]
51pub struct MediaOwner {
52 pub id: String,
53 pub username: String,
54 pub profile_pic_url: Option<String>,
55 pub is_verified: bool,
56}
57
58#[derive(Debug, Clone, Serialize, Deserialize)]
59pub struct TaggedUser {
60 pub id: String,
61 pub username: String,
62}
63
64#[derive(Debug, Clone, Serialize, Deserialize)]
65pub struct Location {
66 pub id: String,
67 pub name: String,
68 pub slug: Option<String>,
69}
70
71#[derive(Debug, Clone, Serialize, Deserialize)]
72pub struct Reel {
73 pub id: String,
74 pub shortcode: String,
75 pub caption: Option<String>,
76 pub timestamp: i64,
77 pub like_count: u64,
78 pub comment_count: u64,
79 pub play_count: u64,
80 pub view_count: u64,
81 pub video_url: String,
82 pub thumbnail_url: String,
83 pub duration: f64,
84 pub owner: MediaOwner,
85 pub audio: Option<ReelAudio>,
86}
87
88#[derive(Debug, Clone, Serialize, Deserialize)]
89pub struct ReelAudio {
90 pub id: String,
91 pub title: String,
92 pub artist: Option<String>,
93}
94
95#[derive(Debug, Clone, Serialize, Deserialize)]
96pub struct Comment {
97 pub id: String,
98 pub text: String,
99 pub timestamp: i64,
100 pub like_count: u64,
101 pub owner: CommentOwner,
102 pub replies: Vec<Comment>,
103}
104
105#[derive(Debug, Clone, Serialize, Deserialize)]
106pub struct CommentOwner {
107 pub id: String,
108 pub username: String,
109 pub profile_pic_url: Option<String>,
110 pub is_verified: bool,
111}
112
113#[derive(Debug, Clone, Serialize, Deserialize)]
114pub struct Like {
115 pub id: String,
116 pub username: String,
117 pub full_name: Option<String>,
118 pub profile_pic_url: Option<String>,
119 pub is_verified: bool,
120}
121
122#[derive(Debug, Clone, Serialize, Deserialize)]
123pub struct Story {
124 pub id: String,
125 pub media_type: MediaType,
126 pub timestamp: i64,
127 pub expiring_at: i64,
128 pub display_url: String,
129 pub video_url: Option<String>,
130 pub owner: MediaOwner,
131}
132
133#[derive(Debug, Clone, Serialize, Deserialize)]
134pub struct Highlight {
135 pub id: String,
136 pub title: String,
137 pub cover_url: String,
138 pub media_count: u64,
139 pub items: Vec<Story>,
140}
141
142#[derive(Debug, Clone, Serialize, Deserialize)]
143pub struct SearchResult {
144 pub users: Vec<UserSearchItem>,
145 pub hashtags: Vec<HashtagSearchItem>,
146 pub places: Vec<PlaceSearchItem>,
147}
148
149#[derive(Debug, Clone, Serialize, Deserialize)]
150pub struct UserSearchItem {
151 pub id: String,
152 pub username: String,
153 pub full_name: Option<String>,
154 pub profile_pic_url: Option<String>,
155 pub is_verified: bool,
156 pub is_private: bool,
157 pub follower_count: Option<u64>,
158}
159
160#[derive(Debug, Clone, Serialize, Deserialize)]
161pub struct HashtagSearchItem {
162 pub id: String,
163 pub name: String,
164 pub media_count: u64,
165}
166
167#[derive(Debug, Clone, Serialize, Deserialize)]
168pub struct PlaceSearchItem {
169 pub id: String,
170 pub name: String,
171 pub address: Option<String>,
172}
173
174#[derive(Debug, Clone, Serialize, Deserialize)]
175pub struct Pagination<T> {
176 pub items: Vec<T>,
177 pub has_next: bool,
178 pub cursor: Option<String>,
179}
180
181impl<T> Default for Pagination<T> {
182 fn default() -> Self {
183 Self {
184 items: Vec::new(),
185 has_next: false,
186 cursor: None,
187 }
188 }
189}