use crate::model::*;
use crate::JyveClient;
use serde_json::json;
#[derive(Clone)]
pub struct UsersListRequest<'a> {
pub(crate) http_client: &'a JyveClient,
pub email: Option<String>,
pub first_name: Option<String>,
pub full_name: Option<String>,
pub id: Option<f64>,
pub ids: Option<String>,
pub last_name: Option<String>,
pub ordering: Option<String>,
pub page: Option<i64>,
pub page_size: Option<i64>,
pub phone_number: Option<String>,
pub q: Option<String>,
}
impl<'a> UsersListRequest<'a> {
pub async fn send(self) -> ::httpclient::InMemoryResult<Vec<User>> {
let mut r = self.http_client.client.get("/users/");
if let Some(ref unwrapped) = self.email {
r = r.query("email", &unwrapped.to_string());
}
if let Some(ref unwrapped) = self.first_name {
r = r.query("first_name", &unwrapped.to_string());
}
if let Some(ref unwrapped) = self.full_name {
r = r.query("full_name", &unwrapped.to_string());
}
if let Some(ref unwrapped) = self.id {
r = r.query("id", &unwrapped.to_string());
}
if let Some(ref unwrapped) = self.ids {
r = r.query("ids", &unwrapped.to_string());
}
if let Some(ref unwrapped) = self.last_name {
r = r.query("last_name", &unwrapped.to_string());
}
if let Some(ref unwrapped) = self.ordering {
r = r.query("ordering", &unwrapped.to_string());
}
if let Some(ref unwrapped) = self.page {
r = r.query("page", &unwrapped.to_string());
}
if let Some(ref unwrapped) = self.page_size {
r = r.query("page_size", &unwrapped.to_string());
}
if let Some(ref unwrapped) = self.phone_number {
r = r.query("phone_number", &unwrapped.to_string());
}
if let Some(ref unwrapped) = self.q {
r = r.query("q", &unwrapped.to_string());
}
r = self.http_client.authenticate(r);
let res = r.send_awaiting_body().await?;
res.json()
}
pub fn email(mut self, email: &str) -> Self {
self.email = Some(email.to_owned());
self
}
pub fn first_name(mut self, first_name: &str) -> Self {
self.first_name = Some(first_name.to_owned());
self
}
pub fn full_name(mut self, full_name: &str) -> Self {
self.full_name = Some(full_name.to_owned());
self
}
pub fn id(mut self, id: f64) -> Self {
self.id = Some(id);
self
}
pub fn ids(mut self, ids: &str) -> Self {
self.ids = Some(ids.to_owned());
self
}
pub fn last_name(mut self, last_name: &str) -> Self {
self.last_name = Some(last_name.to_owned());
self
}
pub fn ordering(mut self, ordering: &str) -> Self {
self.ordering = Some(ordering.to_owned());
self
}
pub fn page(mut self, page: i64) -> Self {
self.page = Some(page);
self
}
pub fn page_size(mut self, page_size: i64) -> Self {
self.page_size = Some(page_size);
self
}
pub fn phone_number(mut self, phone_number: &str) -> Self {
self.phone_number = Some(phone_number.to_owned());
self
}
pub fn q(mut self, q: &str) -> Self {
self.q = Some(q.to_owned());
self
}
}
impl<'a> ::std::future::IntoFuture for UsersListRequest<'a> {
type Output = httpclient::InMemoryResult<Vec<User>>;
type IntoFuture = ::futures::future::BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(self.send())
}
}