use crate::model::*;
use crate::JyveClient;
use serde_json::json;
#[derive(Clone)]
pub struct NotificationsListRequest<'a> {
pub(crate) http_client: &'a JyveClient,
pub action_was_taken: Option<String>,
pub created_at_gte: Option<String>,
pub id: Option<f64>,
pub ordering: Option<String>,
pub page: Option<i64>,
pub page_size: Option<i64>,
pub should_hide: Option<String>,
pub updated_at_gte: Option<String>,
}
impl<'a> NotificationsListRequest<'a> {
pub async fn send(self) -> ::httpclient::InMemoryResult<Vec<Notification>> {
let mut r = self.http_client.client.get("/notifications/");
if let Some(ref unwrapped) = self.action_was_taken {
r = r.query("action_was_taken", &unwrapped.to_string());
}
if let Some(ref unwrapped) = self.created_at_gte {
r = r.query("created_at__gte", &unwrapped.to_string());
}
if let Some(ref unwrapped) = self.id {
r = r.query("id", &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.should_hide {
r = r.query("should_hide", &unwrapped.to_string());
}
if let Some(ref unwrapped) = self.updated_at_gte {
r = r.query("updated_at__gte", &unwrapped.to_string());
}
r = self.http_client.authenticate(r);
let res = r.send_awaiting_body().await?;
res.json()
}
pub fn action_was_taken(mut self, action_was_taken: &str) -> Self {
self.action_was_taken = Some(action_was_taken.to_owned());
self
}
pub fn created_at_gte(mut self, created_at_gte: &str) -> Self {
self.created_at_gte = Some(created_at_gte.to_owned());
self
}
pub fn id(mut self, id: f64) -> Self {
self.id = Some(id);
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 should_hide(mut self, should_hide: &str) -> Self {
self.should_hide = Some(should_hide.to_owned());
self
}
pub fn updated_at_gte(mut self, updated_at_gte: &str) -> Self {
self.updated_at_gte = Some(updated_at_gte.to_owned());
self
}
}
impl<'a> ::std::future::IntoFuture for NotificationsListRequest<'a> {
type Output = httpclient::InMemoryResult<Vec<Notification>>;
type IntoFuture = ::futures::future::BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(self.send())
}
}