use crate::product::{Product, ProductCreate, ProductUpdate};
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::resource_ops;
use super::transport::Transport;
pub const API_PATH: &str = "tmf-api/productInventory/v5";
pub const SPEC_VERSION: &str = "5.0.0";
const PRODUCTS: &str = "product";
#[derive(Debug, Clone)]
pub struct ProductInventoryClient {
inner: TmfClient,
}
impl ProductInventoryClient {
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!(
PRODUCTS,
read = Product,
create = ProductCreate,
update = ProductUpdate,
list = list_products,
stream = stream_products,
get = get_product,
new = create_product,
patch = update_product,
delete = delete_product,
doc = "a product"
);
}
impl HubOps for ProductInventoryClient {
fn hub_client(&self) -> &TmfClient {
&self.inner
}
}