use crate::bill::{
AppliedCustomerBillingRate, BillCycle, CustomerBill, CustomerBillOnDemand,
CustomerBillOnDemandCreate, CustomerBillUpdate,
};
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::{Api, Collection, Operation};
use super::{op_get, op_list, op_patch, op_stream, readonly_ops, task_ops};
pub const API_PATH: &str = "tmf-api/customerBillManagement/v5";
pub const SPEC_VERSION: &str = "5.0.0";
pub const API: Api = Api::new(
"TMF678",
API_PATH,
SPEC_VERSION,
&[
Collection::read_only("appliedCustomerBillingRate"),
Collection::read_only("billCycle"),
Collection::new(
"customerBill",
&[Operation::List, Operation::Retrieve, Operation::Update],
),
Collection::task("customerBillOnDemand"),
Collection::new("hub", &[Operation::Create, Operation::Delete]),
],
);
const BILLS: &str = "customerBill";
const ON_DEMAND: &str = "customerBillOnDemand";
const RATES: &str = "appliedCustomerBillingRate";
const CYCLES: &str = "billCycle";
#[derive(Debug, Clone)]
pub struct CustomerBillClient {
inner: TmfClient,
}
impl CustomerBillClient {
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
}
op_list!(BILLS, CustomerBill, list_customer_bills, "a customer bill");
op_stream!(
BILLS,
CustomerBill,
stream_customer_bills,
"a customer bill"
);
op_get!(BILLS, CustomerBill, get_customer_bill, "a customer bill");
op_patch!(
BILLS,
CustomerBill,
CustomerBillUpdate,
update_customer_bill,
"a customer bill"
);
task_ops!(
ON_DEMAND,
read = CustomerBillOnDemand,
create = CustomerBillOnDemandCreate,
list = list_on_demand_requests,
stream = stream_on_demand_requests,
get = get_on_demand_request,
new = request_bill_on_demand,
doc = "an on-demand bill request"
);
readonly_ops!(
RATES,
read = AppliedCustomerBillingRate,
list = list_applied_billing_rates,
stream = stream_applied_billing_rates,
get = get_applied_billing_rate,
doc = "an applied billing rate"
);
readonly_ops!(
CYCLES,
read = BillCycle,
list = list_bill_cycles,
stream = stream_bill_cycles,
get = get_bill_cycle,
doc = "a bill cycle"
);
}
impl HubOps for CustomerBillClient {
fn hub_client(&self) -> &TmfClient {
&self.inner
}
}