use crate::customer::{Customer, CustomerCreate, CustomerUpdate};
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/customerManagement/v5";
pub const SPEC_VERSION: &str = "5.0.1";
const CUSTOMERS: &str = "customer";
#[derive(Debug, Clone)]
pub struct CustomerClient {
inner: TmfClient,
}
impl CustomerClient {
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!(
CUSTOMERS,
read = Customer,
create = CustomerCreate,
update = CustomerUpdate,
list = list_customers,
stream = stream_customers,
get = get_customer,
new = create_customer,
patch = update_customer,
delete = delete_customer,
doc = "a customer"
);
}
impl HubOps for CustomerClient {
fn hub_client(&self) -> &TmfClient {
&self.inner
}
}