summaryrefslogtreecommitdiff
path: root/src/helix/models.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/helix/models.rs')
-rw-r--r--src/helix/models.rs46
1 files changed, 26 insertions, 20 deletions
diff --git a/src/helix/models.rs b/src/helix/models.rs
index 2b01e7c..e4c58c3 100644
--- a/src/helix/models.rs
+++ b/src/helix/models.rs
@@ -1,8 +1,9 @@
extern crate serde_json;
extern crate chrono;
-use chrono::{Duration, DateTime, Utc};
-
+use url::Url;
+use chrono::{DateTime, Utc};
+use super::types::{UserId, VideoId, ChannelId};
#[derive(Debug, Deserialize)]
pub struct DataContainer<T> {
@@ -22,17 +23,17 @@ pub struct PaginationContainer<T> {
#[derive(Debug, Deserialize)]
pub struct Video {
- pub id: String,
- pub user_id: String,
+ pub id: VideoId,
+ pub user_id: UserId,
pub user_name: String,
pub title: String,
pub description: String,
- //Should be converted to a DateTime
- pub created_at: String,
- pub published_at: String,
- //Should be converted to a URL
- pub url: String,
- pub thumbnail_url: String,
+ pub created_at: DateTime<Utc>,
+ pub published_at: DateTime<Utc>,
+ #[serde(with = "url_serde")]
+ pub url: Url,
+ #[serde(with = "url_serde")]
+ pub thumbnail_url: Url,
pub viewable: String,
pub view_count: i32,
pub language: String,
@@ -44,15 +45,17 @@ pub struct Video {
#[derive(Debug, Deserialize)]
pub struct User {
- pub id: String,
+ pub id: UserId,
pub login: String,
pub display_name: String,
#[serde(rename = "type")]
pub user_type: String,
pub broadcaster_type: String,
pub description: String,
- pub profile_image_url: String,
- pub offline_image_url: String,
+ #[serde(with = "url_serde")]
+ pub profile_image_url: Url,
+ #[serde(with = "url_serde")]
+ pub offline_image_url: Url,
pub view_count: u32,
pub email: Option<String>,
}
@@ -60,17 +63,20 @@ pub struct User {
#[derive(Debug, Deserialize)]
pub struct Clip {
pub id: String,
- pub url: String,
- pub embed_url: String,
- pub broadcaster_id: String,
+ #[serde(with = "url_serde")]
+ pub url: Url,
+ #[serde(with = "url_serde")]
+ pub embed_url: Url,
+ pub broadcaster_id: ChannelId,
pub broadcaster_name: String,
- pub creator_id: String,
+ pub creator_id: UserId,
pub creator_name: String,
- pub video_id: String,
+ pub video_id: VideoId,
pub game_id: String,
pub language: String,
pub title: String,
- pub created_at: String,
- pub thumbnail_url: String,
+ pub created_at: DateTime<Utc>,
+ #[serde(with = "url_serde")]
+ pub thumbnail_url: Url,
pub view_count: i32,
}