summaryrefslogtreecommitdiff
path: root/twitch_api/src/helix/namespaces/users.rs
diff options
context:
space:
mode:
Diffstat (limited to 'twitch_api/src/helix/namespaces/users.rs')
-rw-r--r--twitch_api/src/helix/namespaces/users.rs44
1 files changed, 44 insertions, 0 deletions
diff --git a/twitch_api/src/helix/namespaces/users.rs b/twitch_api/src/helix/namespaces/users.rs
new file mode 100644
index 0000000..2e922d6
--- /dev/null
+++ b/twitch_api/src/helix/namespaces/users.rs
@@ -0,0 +1,44 @@
+use super::*;
+use super::models::{DataContainer, User};
+use std::string::ToString;
+
+pub struct Users {}
+type UsersNamespace = Namespace<Users>;
+
+impl UsersNamespace {
+ pub fn users<S: ToString>(self, ids: &[S], logins: &[S]) -> ApiRequest<DataContainer<User>> {
+ use self::users;
+ users(self.client, ids, logins)
+ }
+}
+
+impl Client {
+ pub fn users(&self) -> UsersNamespace {
+ UsersNamespace::new(self)
+ }
+}
+
+pub fn users<S: ToString>(
+ client: Client,
+ ids: &[S],
+ logins: &[S],
+ ) -> ApiRequest<DataContainer<User>> {
+ let client = client.inner;
+ let url =
+ String::from("https://") + client.domain() + &String::from("/helix/users");
+
+ let mut params: BTreeMap<&str, &dyn ToString> = BTreeMap::new();
+ for id in ids {
+ params.insert("id", id);
+ }
+
+ for login in logins {
+ params.insert("login", login);
+ }
+
+ ApiRequest::new(url, params, client, Method::GET, Some(RatelimitKey::Default))
+}
+
+pub fn authed_as(client: Client) -> ApiRequest<DataContainer<User>> {
+ users(client, &[""], &[""])
+}