summaryrefslogtreecommitdiff
path: root/src/helix/models.rs
diff options
context:
space:
mode:
authorDavid Blajda <blajda@hotmail.com>2019-05-08 15:38:37 +0000
committerDavid Blajda <blajda@hotmail.com>2019-05-08 15:38:37 +0000
commit98fb79b85e3cfbb547e5340b30623511daf09ef5 (patch)
treea03bd7a95c86a92eb7510409429f50433056d7ab /src/helix/models.rs
parent0e09c2c06fc0b81f11d12985a4172c815233db17 (diff)
:WIP: Move types to a different crate
Diffstat (limited to 'src/helix/models.rs')
-rw-r--r--src/helix/models.rs118
1 files changed, 0 insertions, 118 deletions
diff --git a/src/helix/models.rs b/src/helix/models.rs
deleted file mode 100644
index 1e9f0ec..0000000
--- a/src/helix/models.rs
+++ /dev/null
@@ -1,118 +0,0 @@
-extern crate serde_json;
-extern crate chrono;
-
-use url::Url;
-use chrono::{DateTime, Utc};
-use crate::types::{UserId, VideoId, ChannelId};
-
-use crate::client::PaginationTrait;
-
-#[derive(Debug, Deserialize, Serialize)]
-pub struct DataContainer<T> {
- pub data: Vec<T>
-}
-
-impl<T> PaginationTrait for DataContainer<T> {
- fn cursor<'a>(&'a self) -> Option<&'a str> { None }
-}
-
-impl<T> PaginationTrait for PaginationContainer<T> {
- fn cursor<'a>(&'a self) -> Option<&'a str> {
- match self.pagination.as_ref() {
- Some(cursor) => {
- match cursor.cursor.as_ref() {
- Some(cursor) => Some(cursor),
- None => None,
- }
- },
- None => None
- }
- }
-}
-
-impl PaginationTrait for Credentials {
- fn cursor<'a>(&'a self) -> Option<&'a str> { None }
-}
-
-#[derive(Debug, Deserialize, Serialize)]
-pub struct PaginationContainer<T> {
- pub data: Vec<T>,
- pub pagination: Option<Cursor>
-}
-
-#[derive(Debug, Deserialize, Serialize)]
-pub struct Cursor {
- pub cursor: Option<String>
-}
-
-#[derive(Debug, Deserialize, Serialize)]
-pub struct Video {
- pub id: VideoId,
- pub user_id: UserId,
- pub user_name: String,
- pub title: String,
- pub description: String,
- pub created_at: DateTime<Utc>,
- pub published_at: DateTime<Utc>,
- #[serde(with = "url_serde")]
- pub url: Url,
- /*FIXME: Serde will attempt to parse an empty string.
- * In this case this should be None when thumbnail_url is an empty string
- */
- //#[serde(with = "url_serde")]
- pub thumbnail_url: String, //Option<Url>,
- pub viewable: String,
- pub view_count: i32,
- pub language: String,
- #[serde(rename = "type")]
- pub video_type: String,
- //Should be converted to a Duration
- pub duration: String,
-}
-
-#[derive(Debug, Deserialize, Serialize)]
-pub struct User {
- pub id: UserId,
- pub login: String,
- pub display_name: String,
- #[serde(rename = "type")]
- pub user_type: String,
- pub broadcaster_type: String,
- pub description: String,
- #[serde(with = "url_serde")]
- pub profile_image_url: Url,
- //#[serde(with = "url_serde")]
- pub offline_image_url: String, // Option<Url>,
- pub view_count: u32,
- pub email: Option<String>,
-}
-
-#[derive(Debug, Deserialize, Serialize)]
-pub struct Clip {
- pub 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: UserId,
- pub creator_name: String,
- pub video_id: VideoId,
- pub game_id: String,
- pub language: String,
- pub title: String,
- pub created_at: DateTime<Utc>,
- #[serde(with = "url_serde")]
- pub thumbnail_url: Url,
- pub view_count: i32,
-}
-
-#[derive(Debug, Deserialize, Serialize)]
-pub struct Credentials {
- pub access_token: String,
- pub refresh_token: Option<String>,
- pub expires_in: u32,
- pub scope: Option<Vec<String>>,
- pub token_type: String,
-}