summaryrefslogtreecommitdiff
path: root/src/helix/models.rs
diff options
context:
space:
mode:
authorDavid Blajda <blajda@hotmail.com>2018-12-27 04:46:10 +0000
committerDavid Blajda <blajda@hotmail.com>2018-12-27 04:46:10 +0000
commitcb1b144e48ee357a76f551433d4886f092d259c8 (patch)
tree15606dc621e4d68f3bf3e9d27a44e6fd02a00fc5 /src/helix/models.rs
parent2e08d0c8abbfb9f989c61acb4f6c580719a65b42 (diff)
Use a generic client for both helix and kraken
Diffstat (limited to 'src/helix/models.rs')
-rw-r--r--src/helix/models.rs42
1 files changed, 24 insertions, 18 deletions
diff --git a/src/helix/models.rs b/src/helix/models.rs
index 4124fd2..47a1288 100644
--- a/src/helix/models.rs
+++ b/src/helix/models.rs
@@ -3,11 +3,9 @@ extern crate chrono;
use url::Url;
use chrono::{DateTime, Utc};
-use super::types::{UserId, VideoId, ChannelId};
+use crate::types::{UserId, VideoId, ChannelId};
-pub trait PaginationTrait {
- fn cursor<'a>(&'a self) -> &'a Option<Cursor>;
-}
+use crate::client::PaginationTrait;
#[derive(Debug, Deserialize)]
pub struct DataContainer<T> {
@@ -15,15 +13,25 @@ pub struct DataContainer<T> {
}
impl<T> PaginationTrait for DataContainer<T> {
- fn cursor<'a>(&'a self) -> &'a Option<Cursor> { &None }
+ fn cursor<'a>(&'a self) -> Option<&'a str> { None }
}
impl<T> PaginationTrait for PaginationContainer<T> {
- fn cursor<'a>(&'a self) -> &'a Option<Cursor> { &self.pagination }
+ 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) -> &'a Option<Cursor> { &None }
+ fn cursor<'a>(&'a self) -> Option<&'a str> { None }
}
#[derive(Debug, Deserialize)]
@@ -37,17 +45,6 @@ pub struct Cursor {
pub cursor: Option<String>
}
-
-#[derive(Debug, Deserialize)]
-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,
-}
-
-
#[derive(Debug, Deserialize)]
pub struct Video {
pub id: VideoId,
@@ -107,3 +104,12 @@ pub struct Clip {
pub thumbnail_url: Url,
pub view_count: i32,
}
+
+#[derive(Debug, Deserialize)]
+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,
+}