use crate::order::{
CancelProductOrder, CancelProductOrderCreate, ProductOrder, ProductOrderCreate,
ProductOrderUpdate,
};
use super::client::TmfClient;
use super::error::Result;
use super::hub::HubOps;
use super::page::{Page, PageRequest, PageStream, paginate};
use super::patch::Patch;
use super::query::Query;
use super::transport::Transport;
use super::{resource_ops, task_ops};
pub const API_PATH: &str = "tmf-api/productOrderingManagement/v5";
pub const SPEC_VERSION: &str = "5.0.0";
const ORDERS: &str = "productOrder";
const CANCELLATIONS: &str = "cancelProductOrder";
#[derive(Debug, Clone)]
pub struct ProductOrderClient {
inner: TmfClient,
}
impl ProductOrderClient {
pub fn new(base_url: impl Into<String>, transport: impl Transport + 'static) -> Result<Self> {
Ok(Self {
inner: TmfClient::new(base_url, transport)?,
})
}
pub fn from_host(host: &str, transport: impl Transport + 'static) -> Result<Self> {
Self::new(
format!("{}/{API_PATH}", host.trim_end_matches('/')),
transport,
)
}
#[must_use]
pub fn inner(&self) -> &TmfClient {
&self.inner
}
resource_ops!(
ORDERS,
read = ProductOrder,
create = ProductOrderCreate,
update = ProductOrderUpdate,
list = list_product_orders,
stream = stream_product_orders,
get = get_product_order,
new = create_product_order,
patch = update_product_order,
delete = delete_product_order,
doc = "a product order"
);
task_ops!(
CANCELLATIONS,
read = CancelProductOrder,
create = CancelProductOrderCreate,
list = list_cancellations,
stream = stream_cancellations,
get = get_cancellation,
new = request_cancellation,
doc = "a cancellation request"
);
}
impl HubOps for ProductOrderClient {
fn hub_client(&self) -> &TmfClient {
&self.inner
}
}