use crate::ticket::{
TroubleTicket, TroubleTicketCreate, TroubleTicketSpecification,
TroubleTicketSpecificationCreate, TroubleTicketSpecificationUpdate, TroubleTicketUpdate,
};
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/troubleTicket/v5";
pub const SPEC_VERSION: &str = "5.0.1";
const TICKETS: &str = "troubleTicket";
const SPECIFICATIONS: &str = "troubleTicketSpecification";
#[derive(Debug, Clone)]
pub struct TroubleTicketClient {
inner: TmfClient,
}
impl TroubleTicketClient {
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!(
TICKETS,
read = TroubleTicket,
create = TroubleTicketCreate,
update = TroubleTicketUpdate,
list = list_trouble_tickets,
stream = stream_trouble_tickets,
get = get_trouble_ticket,
new = create_trouble_ticket,
patch = update_trouble_ticket,
delete = delete_trouble_ticket,
doc = "a trouble ticket"
);
resource_ops!(
SPECIFICATIONS,
read = TroubleTicketSpecification,
create = TroubleTicketSpecificationCreate,
update = TroubleTicketSpecificationUpdate,
list = list_trouble_ticket_specifications,
stream = stream_trouble_ticket_specifications,
get = get_trouble_ticket_specification,
new = create_trouble_ticket_specification,
patch = update_trouble_ticket_specification,
delete = delete_trouble_ticket_specification,
doc = "a trouble ticket specification"
);
}
impl HubOps for TroubleTicketClient {
fn hub_client(&self) -> &TmfClient {
&self.inner
}
}