From 23ea9413cd0e29eb451df08c5c799d64f56a1342 Mon Sep 17 00:00:00 2001 From: David Blajda Date: Sun, 16 Dec 2018 21:45:58 +0000 Subject: Move endpoints functions into namespaces --- src/helix/namespaces/clips.rs | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/helix/namespaces/clips.rs (limited to 'src/helix/namespaces/clips.rs') diff --git a/src/helix/namespaces/clips.rs b/src/helix/namespaces/clips.rs new file mode 100644 index 0000000..32793c0 --- /dev/null +++ b/src/helix/namespaces/clips.rs @@ -0,0 +1,42 @@ +use futures::future::Future; +use super::super::models::{DataContainer, PaginationContainer, User, Video, Clip}; +use super::super::Client; +const API_DOMAIN: &'static str = "api.twitch.tv"; +use super::super::Namespace; + +pub struct Clips {} +type ClipsNamespace = Namespace; + +impl ClipsNamespace { + pub fn clip(self, id: &str) -> impl Future, Error=reqwest::Error> { + use self::clip; + clip(self.client, id) + } +} + +impl Client { + + pub fn clips(&self) -> ClipsNamespace { + ClipsNamespace::new(self) + } +} + +pub fn clip(client: Client, id: &str) + -> impl Future, Error=reqwest::Error> +{ + let url = + String::from("https://") + + API_DOMAIN + "/helix/clips" + "?id=" + id; + + + let request = client.client().get(&url); + let request = client.apply_standard_headers(request); + + request + .send() + .map(|mut res| { + println!("{:?}", res); + res.json::>() + }) + .and_then(|json| json) +} -- cgit v1.2.3