use crate::model::*;
use crate::JyveClient;
use serde_json::json;
#[derive(Clone)]
pub struct DeliveriesListRequest<'a> {
pub(crate) http_client: &'a JyveClient,
pub arrival_time_gt: Option<String>,
pub arrival_time_gte: Option<String>,
pub arrival_time_lt: Option<String>,
pub arrival_time_lte: Option<String>,
pub date_completed_gt: Option<String>,
pub date_completed_gte: Option<String>,
pub date_completed_lt: Option<String>,
pub date_completed_lte: Option<String>,
pub has_been_completed: Option<String>,
pub id: Option<f64>,
pub ids: Option<String>,
pub ordering: Option<String>,
pub page: Option<i64>,
pub page_size: Option<i64>,
pub store_groups: Option<String>,
pub store_location: Option<f64>,
pub store_locations: Option<String>,
}
impl<'a> DeliveriesListRequest<'a> {
pub async fn send(self) -> ::httpclient::InMemoryResult<Vec<Delivery>> {
let mut r = self.http_client.client.get("/deliveries/");
if let Some(ref unwrapped) = self.arrival_time_gt {
r = r.query("arrival_time__gt", &unwrapped.to_string());
}
if let Some(ref unwrapped) = self.arrival_time_gte {
r = r.query("arrival_time__gte", &unwrapped.to_string());
}
if let Some(ref unwrapped) = self.arrival_time_lt {
r = r.query("arrival_time__lt", &unwrapped.to_string());
}
if let Some(ref unwrapped) = self.arrival_time_lte {
r = r.query("arrival_time__lte", &unwrapped.to_string());
}
if let Some(ref unwrapped) = self.date_completed_gt {
r = r.query("date_completed__gt", &unwrapped.to_string());
}
if let Some(ref unwrapped) = self.date_completed_gte {
r = r.query("date_completed__gte", &unwrapped.to_string());
}
if let Some(ref unwrapped) = self.date_completed_lt {
r = r.query("date_completed__lt", &unwrapped.to_string());
}
if let Some(ref unwrapped) = self.date_completed_lte {
r = r.query("date_completed__lte", &unwrapped.to_string());
}
if let Some(ref unwrapped) = self.has_been_completed {
r = r.query("has_been_completed", &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.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.store_groups {
r = r.query("store_groups", &unwrapped.to_string());
}
if let Some(ref unwrapped) = self.store_location {
r = r.query("store_location", &unwrapped.to_string());
}
if let Some(ref unwrapped) = self.store_locations {
r = r.query("store_locations", &unwrapped.to_string());
}
r = self.http_client.authenticate(r);
let res = r.send_awaiting_body().await?;
res.json()
}
pub fn arrival_time_gt(mut self, arrival_time_gt: &str) -> Self {
self.arrival_time_gt = Some(arrival_time_gt.to_owned());
self
}
pub fn arrival_time_gte(mut self, arrival_time_gte: &str) -> Self {
self.arrival_time_gte = Some(arrival_time_gte.to_owned());
self
}
pub fn arrival_time_lt(mut self, arrival_time_lt: &str) -> Self {
self.arrival_time_lt = Some(arrival_time_lt.to_owned());
self
}
pub fn arrival_time_lte(mut self, arrival_time_lte: &str) -> Self {
self.arrival_time_lte = Some(arrival_time_lte.to_owned());
self
}
pub fn date_completed_gt(mut self, date_completed_gt: &str) -> Self {
self.date_completed_gt = Some(date_completed_gt.to_owned());
self
}
pub fn date_completed_gte(mut self, date_completed_gte: &str) -> Self {
self.date_completed_gte = Some(date_completed_gte.to_owned());
self
}
pub fn date_completed_lt(mut self, date_completed_lt: &str) -> Self {
self.date_completed_lt = Some(date_completed_lt.to_owned());
self
}
pub fn date_completed_lte(mut self, date_completed_lte: &str) -> Self {
self.date_completed_lte = Some(date_completed_lte.to_owned());
self
}
pub fn has_been_completed(mut self, has_been_completed: &str) -> Self {
self.has_been_completed = Some(has_been_completed.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 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 store_groups(mut self, store_groups: &str) -> Self {
self.store_groups = Some(store_groups.to_owned());
self
}
pub fn store_location(mut self, store_location: f64) -> Self {
self.store_location = Some(store_location);
self
}
pub fn store_locations(mut self, store_locations: &str) -> Self {
self.store_locations = Some(store_locations.to_owned());
self
}
}
impl<'a> ::std::future::IntoFuture for DeliveriesListRequest<'a> {
type Output = httpclient::InMemoryResult<Vec<Delivery>>;
type IntoFuture = ::futures::future::BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(self.send())
}
}