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