summaryrefslogtreecommitdiff
path: root/src/helix/namespaces/users.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/users.rs
parentcb1b144e48ee357a76f551433d4886f092d259c8 (diff)
Use Id types for endpoints and implement kraken headers
Diffstat (limited to 'src/helix/namespaces/users.rs')
-rw-r--r--src/helix/namespaces/users.rs55
1 files changed, 22 insertions, 33 deletions
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<Users>;
impl UsersNamespace {
- /*
- pub fn users(self, id: Vec<&str>, login: Vec<&str>) -> impl Future<Item=DataContainer<User>, Error=reqwest::Error> {
- //use self::users;
- //users(self.client, id, login)
+ pub fn users(self, ids: Vec<&UserId>, logins: Vec<&str>)
+ -> ApiRequest<DataContainer<User>> {
+ 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<Item = DataContainer<User>, Error = reqwest::Error> {
+ ids: Vec<&UserId>,
+ logins: Vec<&str>,
+ ) -> ApiRequest<DataContainer<User>> {
+ 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(&params);
+ ApiRequest::new(url, params, client, Method::GET, Some(RatelimitKey::Default))
+}
- request
- .send()
- .map(|mut res| {
- res.json::<DataContainer<User>>()
- })
- .and_then(|json| json)
+pub fn authed_as(client: Client) -> ApiRequest<DataContainer<User>> {
+ users(client, Vec::with_capacity(0), Vec::with_capacity(0))
}
-*/