From 678e3d3f28cb8594204dc5e2b7597ae66a4582c7 Mon Sep 17 00:00:00 2001 From: David Blajda Date: Thu, 27 Dec 2018 22:03:23 +0000 Subject: Use Id types for endpoints and implement kraken headers --- src/helix/namespaces/users.rs | 55 +++++++++++++++++-------------------------- 1 file changed, 22 insertions(+), 33 deletions(-) (limited to 'src/helix/namespaces/users.rs') diff --git a/src/helix/namespaces/users.rs b/src/helix/namespaces/users.rs index 3e4f1dd..20f2914 100644 --- a/src/helix/namespaces/users.rs +++ b/src/helix/namespaces/users.rs @@ -1,56 +1,45 @@ -use futures::future::Future; -use super::super::models::{DataContainer, PaginationContainer, User, Video, Clip}; -use super::super::Client; -use std::collections::BTreeMap; -const API_DOMAIN: &'static str = "api.twitch.tv"; -use super::Namespace; +use super::*; +use super::models::{DataContainer, User}; +use crate::types::UserId; pub struct Users {} type UsersNamespace = Namespace; impl UsersNamespace { - /* - pub fn users(self, id: Vec<&str>, login: Vec<&str>) -> impl Future, Error=reqwest::Error> { - //use self::users; - //users(self.client, id, login) + pub fn users(self, ids: Vec<&UserId>, logins: Vec<&str>) + -> ApiRequest> { + use self::users; + users(self.client, ids, logins) } - */ } -/* -impl Client { +impl Client { pub fn users(&self) -> UsersNamespace { UsersNamespace::new(self) } } -*/ -/* + pub fn users( client: Client, - id: Vec<&str>, - login: Vec<&str>, - ) -> impl Future, Error = reqwest::Error> { + ids: Vec<&UserId>, + logins: Vec<&str>, + ) -> ApiRequest> { + let client = client.inner; let url = - String::from("https://") + &String::from(API_DOMAIN) + &String::from("/helix/users"); + String::from("https://") + client.domain() + &String::from("/helix/users"); let mut params = BTreeMap::new(); - for i in id { - params.insert("id", i); + for id in ids { + params.insert("id", id.as_ref()); } - for log in login { - params.insert("login", log); + for login in logins { + params.insert("login", login); } - let request = client.client().get(&url); - let request = client.apply_standard_headers(request); - let request = request.query(¶ms); + ApiRequest::new(url, params, client, Method::GET, Some(RatelimitKey::Default)) +} - request - .send() - .map(|mut res| { - res.json::>() - }) - .and_then(|json| json) +pub fn authed_as(client: Client) -> ApiRequest> { + users(client, Vec::with_capacity(0), Vec::with_capacity(0)) } -*/ -- cgit v1.2.3