summaryrefslogtreecommitdiff
path: root/src/helix/namespaces/videos.rs
diff options
context:
space:
mode:
authorDavid Blajda <blajda@hotmail.com>2018-12-27 22:03:23 +0000
committerDavid Blajda <blajda@hotmail.com>2018-12-27 22:03:23 +0000
commit678e3d3f28cb8594204dc5e2b7597ae66a4582c7 (patch)
tree55b563cfdc09dab8f18c1f4d688ebf0c2187985c /src/helix/namespaces/videos.rs
parentcb1b144e48ee357a76f551433d4886f092d259c8 (diff)
Use Id types for endpoints and implement kraken headers
Diffstat (limited to 'src/helix/namespaces/videos.rs')
-rw-r--r--src/helix/namespaces/videos.rs28
1 files changed, 12 insertions, 16 deletions
diff --git a/src/helix/namespaces/videos.rs b/src/helix/namespaces/videos.rs
index a8021f3..75b702e 100644
--- a/src/helix/namespaces/videos.rs
+++ b/src/helix/namespaces/videos.rs
@@ -1,29 +1,25 @@
-use super::super::models::{PaginationContainer, Video};
-use super::super::Client;
-use super::Namespace;
-
-use crate::client::{ClientTrait, RatelimitKey, IterableApiRequest};
-use std::collections::BTreeMap;
-use reqwest::Method;
+use super::*;
+use super::models::{PaginationContainer, Video};
+use crate::types::{UserId, GameId, VideoId};
pub struct Videos {}
type VideosNamespace = Namespace<Videos>;
impl VideosNamespace {
- pub fn by_id(self, ids: Vec<&str>)
+ pub fn by_id(self, ids: Vec<&VideoId>)
-> IterableApiRequest<PaginationContainer<Video>> {
use self::by_id;
by_id(self.client, ids)
}
- pub fn by_user(self, user_id: &str)
+ pub fn by_user(self, user_id: &UserId)
-> IterableApiRequest<PaginationContainer<Video>> {
use self::by_user;
by_user(self.client, user_id)
}
- pub fn for_game(self, game_id: &str)
+ pub fn for_game(self, game_id: &GameId)
-> IterableApiRequest<PaginationContainer<Video>> {
use self::for_game;
for_game(self.client, game_id)
@@ -37,7 +33,7 @@ impl Client {
}
}
-pub fn by_id(client: Client, ids: Vec<&str>)
+pub fn by_id(client: Client, ids: Vec<&VideoId>)
-> IterableApiRequest<PaginationContainer<Video>> {
let client = client.inner;
let url =
@@ -45,34 +41,34 @@ pub fn by_id(client: Client, ids: Vec<&str>)
let mut params = BTreeMap::new();
for id in ids {
- params.insert("id", id);
+ params.insert("id", id.as_ref());
}
IterableApiRequest::new(url, params, client,
Method::GET, Some(RatelimitKey::Default))
}
-pub fn by_user(client: Client, user_id: &str)
+pub fn by_user(client: Client, user_id: &UserId)
-> IterableApiRequest<PaginationContainer<Video>> {
let client = client.inner;
let url =
String::from("https://") + client.domain() + &String::from("/helix/videos");
let mut params = BTreeMap::new();
- params.insert("user_id", user_id);
+ params.insert("user_id", user_id.as_ref());
IterableApiRequest::new(url, params, client,
Method::GET, Some(RatelimitKey::Default))
}
-pub fn for_game(client: Client, game_id: &str)
+pub fn for_game(client: Client, game_id: &GameId)
-> IterableApiRequest<PaginationContainer<Video>> {
let client = client.inner;
let url =
String::from("https://") + client.domain() + &String::from("/helix/videos");
let mut params = BTreeMap::new();
- params.insert("game_id", game_id);
+ params.insert("game_id", game_id.as_ref());
IterableApiRequest::new(url, params, client,
Method::GET, Some(RatelimitKey::Default))