use crate::runtime::{
push_query_param, ApiClient, ApiError, HttpMethod, QueryParam, ResponseEnvelope,
};
use serde::de::DeserializeOwned;
use serde_json::Value;
pub struct IReservationsController;
pub mod get {
use super::*;
#[async_trait::async_trait]
pub trait Overload {
type Output: DeserializeOwned;
async fn call(self, api: &ApiClient) -> Result<ResponseEnvelope<Self::Output>, ApiError>;
async fn call_raw(self, api: &ApiClient) -> Result<ResponseEnvelope<Value>, ApiError>;
}
pub struct List;
#[async_trait::async_trait]
impl Overload for List {
type Output =
Vec<crate::web_api::interface::reservations::view_models::ReservationListElement>;
async fn call(self, api: &ApiClient) -> Result<ResponseEnvelope<Self::Output>, ApiError> {
let query = vec![];
api.request_no_body::<Vec<crate::web_api::interface::reservations::view_models::ReservationListElement>>(HttpMethod::Get, "/api/Reservations", query).await
}
async fn call_raw(self, api: &ApiClient) -> Result<ResponseEnvelope<Value>, ApiError> {
let query = vec![];
api.request_no_body_raw(HttpMethod::Get, "/api/Reservations", query)
.await
}
}
pub struct ById {
pub id: i32,
}
#[async_trait::async_trait]
impl Overload for ById {
type Output = crate::web_api::interface::reservations::view_models::Reservation;
async fn call(self, api: &ApiClient) -> Result<ResponseEnvelope<Self::Output>, ApiError> {
let mut query = Vec::<QueryParam>::new();
push_query_param(&mut query, "id", &self.id)?;
api.request_no_body::<crate::web_api::interface::reservations::view_models::Reservation>(HttpMethod::Get, "/api/Reservations", query).await
}
async fn call_raw(self, api: &ApiClient) -> Result<ResponseEnvelope<Value>, ApiError> {
let mut query = Vec::<QueryParam>::new();
push_query_param(&mut query, "id", &self.id)?;
api.request_no_body_raw(HttpMethod::Get, "/api/Reservations", query)
.await
}
}
}
pub mod get_list_by_contractor {
use super::*;
#[async_trait::async_trait]
pub trait Overload {
type Output: DeserializeOwned;
async fn call(self, api: &ApiClient) -> Result<ResponseEnvelope<Self::Output>, ApiError>;
async fn call_raw(self, api: &ApiClient) -> Result<ResponseEnvelope<Value>, ApiError>;
}
pub struct ByContractorId {
pub contractor_id: i32,
}
#[async_trait::async_trait]
impl Overload for ByContractorId {
type Output =
Vec<crate::web_api::interface::reservations::view_models::ReservationListElement>;
async fn call(self, api: &ApiClient) -> Result<ResponseEnvelope<Self::Output>, ApiError> {
let mut query = Vec::<QueryParam>::new();
push_query_param(&mut query, "contractorId", &self.contractor_id)?;
api.request_no_body::<Vec<crate::web_api::interface::reservations::view_models::ReservationListElement>>(HttpMethod::Get, "/api/Reservations/Filter", query).await
}
async fn call_raw(self, api: &ApiClient) -> Result<ResponseEnvelope<Value>, ApiError> {
let mut query = Vec::<QueryParam>::new();
push_query_param(&mut query, "contractorId", &self.contractor_id)?;
api.request_no_body_raw(HttpMethod::Get, "/api/Reservations/Filter", query)
.await
}
}
pub struct ByContractorCode {
pub contractor_code: String,
}
#[async_trait::async_trait]
impl Overload for ByContractorCode {
type Output =
Vec<crate::web_api::interface::reservations::view_models::ReservationListElement>;
async fn call(self, api: &ApiClient) -> Result<ResponseEnvelope<Self::Output>, ApiError> {
let mut query = Vec::<QueryParam>::new();
push_query_param(&mut query, "contractorCode", &self.contractor_code)?;
api.request_no_body::<Vec<crate::web_api::interface::reservations::view_models::ReservationListElement>>(HttpMethod::Get, "/api/Reservations/Filter", query).await
}
async fn call_raw(self, api: &ApiClient) -> Result<ResponseEnvelope<Value>, ApiError> {
let mut query = Vec::<QueryParam>::new();
push_query_param(&mut query, "contractorCode", &self.contractor_code)?;
api.request_no_body_raw(HttpMethod::Get, "/api/Reservations/Filter", query)
.await
}
}
}
pub mod get_list_by_product {
use super::*;
#[async_trait::async_trait]
pub trait Overload {
type Output: DeserializeOwned;
async fn call(self, api: &ApiClient) -> Result<ResponseEnvelope<Self::Output>, ApiError>;
async fn call_raw(self, api: &ApiClient) -> Result<ResponseEnvelope<Value>, ApiError>;
}
pub struct ByProductId {
pub product_id: i32,
}
#[async_trait::async_trait]
impl Overload for ByProductId {
type Output =
Vec<crate::web_api::interface::reservations::view_models::ReservationListElement>;
async fn call(self, api: &ApiClient) -> Result<ResponseEnvelope<Self::Output>, ApiError> {
let mut query = Vec::<QueryParam>::new();
push_query_param(&mut query, "productId", &self.product_id)?;
api.request_no_body::<Vec<crate::web_api::interface::reservations::view_models::ReservationListElement>>(HttpMethod::Get, "/api/Reservations/Filter", query).await
}
async fn call_raw(self, api: &ApiClient) -> Result<ResponseEnvelope<Value>, ApiError> {
let mut query = Vec::<QueryParam>::new();
push_query_param(&mut query, "productId", &self.product_id)?;
api.request_no_body_raw(HttpMethod::Get, "/api/Reservations/Filter", query)
.await
}
}
pub struct ByProductCode {
pub product_code: String,
}
#[async_trait::async_trait]
impl Overload for ByProductCode {
type Output =
Vec<crate::web_api::interface::reservations::view_models::ReservationListElement>;
async fn call(self, api: &ApiClient) -> Result<ResponseEnvelope<Self::Output>, ApiError> {
let mut query = Vec::<QueryParam>::new();
push_query_param(&mut query, "productCode", &self.product_code)?;
api.request_no_body::<Vec<crate::web_api::interface::reservations::view_models::ReservationListElement>>(HttpMethod::Get, "/api/Reservations/Filter", query).await
}
async fn call_raw(self, api: &ApiClient) -> Result<ResponseEnvelope<Value>, ApiError> {
let mut query = Vec::<QueryParam>::new();
push_query_param(&mut query, "productCode", &self.product_code)?;
api.request_no_body_raw(HttpMethod::Get, "/api/Reservations/Filter", query)
.await
}
}
}
#[allow(non_snake_case)]
impl IReservationsController {
pub async fn Get<T>(
api: &ApiClient,
overload: T,
) -> Result<ResponseEnvelope<T::Output>, ApiError>
where
T: get::Overload,
{
overload.call(api).await
}
pub async fn GetRaw<T>(
api: &ApiClient,
overload: T,
) -> Result<ResponseEnvelope<Value>, ApiError>
where
T: get::Overload,
{
overload.call_raw(api).await
}
pub async fn GetListByContractor<T>(
api: &ApiClient,
overload: T,
) -> Result<ResponseEnvelope<T::Output>, ApiError>
where
T: get_list_by_contractor::Overload,
{
overload.call(api).await
}
pub async fn GetListByContractorRaw<T>(
api: &ApiClient,
overload: T,
) -> Result<ResponseEnvelope<Value>, ApiError>
where
T: get_list_by_contractor::Overload,
{
overload.call_raw(api).await
}
pub async fn GetListByProduct<T>(
api: &ApiClient,
overload: T,
) -> Result<ResponseEnvelope<T::Output>, ApiError>
where
T: get_list_by_product::Overload,
{
overload.call(api).await
}
pub async fn GetListByProductRaw<T>(
api: &ApiClient,
overload: T,
) -> Result<ResponseEnvelope<Value>, ApiError>
where
T: get_list_by_product::Overload,
{
overload.call_raw(api).await
}
pub async fn AddNew(
api: &ApiClient,
reservation: &crate::web_api::interface::reservations::view_models::ReservationNew,
) -> Result<
ResponseEnvelope<crate::web_api::interface::reservations::view_models::Reservation>,
ApiError,
> {
let query = vec![];
api.request_with_body::<crate::web_api::interface::reservations::view_models::Reservation, _>(HttpMethod::Post, "/api/Reservations/Create", query, reservation).await
}
pub async fn AddNewRaw(
api: &ApiClient,
reservation: &crate::web_api::interface::reservations::view_models::ReservationNew,
) -> Result<ResponseEnvelope<Value>, ApiError> {
let query = vec![];
api.request_with_body_raw(
HttpMethod::Post,
"/api/Reservations/Create",
query,
reservation,
)
.await
}
pub async fn AdvancedAddNew(
api: &ApiClient,
reservation: &crate::web_api::interface::reservations::view_models::AdvancedReservationNew,
) -> Result<
ResponseEnvelope<crate::web_api::interface::reservations::view_models::Reservation>,
ApiError,
> {
let query = vec![];
api.request_with_body::<crate::web_api::interface::reservations::view_models::Reservation, _>(HttpMethod::Post, "/api/Reservations/AdvancedCreate", query, reservation).await
}
pub async fn AdvancedAddNewRaw(
api: &ApiClient,
reservation: &crate::web_api::interface::reservations::view_models::AdvancedReservationNew,
) -> Result<ResponseEnvelope<Value>, ApiError> {
let query = vec![];
api.request_with_body_raw(
HttpMethod::Post,
"/api/Reservations/AdvancedCreate",
query,
reservation,
)
.await
}
pub async fn Delete(api: &ApiClient, id: i32) -> Result<ResponseEnvelope<()>, ApiError> {
let mut query = Vec::<QueryParam>::new();
push_query_param(&mut query, "id", &id)?;
api.request_no_body::<()>(HttpMethod::Delete, "/api/Reservations/Delete", query)
.await
}
pub async fn DeleteRaw(api: &ApiClient, id: i32) -> Result<ResponseEnvelope<Value>, ApiError> {
let mut query = Vec::<QueryParam>::new();
push_query_param(&mut query, "id", &id)?;
api.request_no_body_raw(HttpMethod::Delete, "/api/Reservations/Delete", query)
.await
}
pub async fn AdvancedDelete(
api: &ApiClient,
id: i32,
) -> Result<ResponseEnvelope<()>, ApiError> {
let mut query = Vec::<QueryParam>::new();
push_query_param(&mut query, "id", &id)?;
api.request_no_body::<()>(
HttpMethod::Delete,
"/api/Reservations/AdvancedDelete",
query,
)
.await
}
pub async fn AdvancedDeleteRaw(
api: &ApiClient,
id: i32,
) -> Result<ResponseEnvelope<Value>, ApiError> {
let mut query = Vec::<QueryParam>::new();
push_query_param(&mut query, "id", &id)?;
api.request_no_body_raw(
HttpMethod::Delete,
"/api/Reservations/AdvancedDelete",
query,
)
.await
}
}