use crate::account::{
Account, AccountCreate, AccountUpdate, BillFormat, BillFormatCreate, BillFormatUpdate,
BillPresentationMedia, BillPresentationMediaCreate, BillPresentationMediaUpdate,
BillingCycleSpecification, BillingCycleSpecificationCreate, BillingCycleSpecificationUpdate,
};
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;
use super::{Api, Collection, Operation};
pub const API_PATH: &str = "tmf-api/accountManagement/v5";
pub const SPEC_VERSION: &str = "5.0.0";
pub const API: Api = Api::new(
"TMF666",
API_PATH,
SPEC_VERSION,
&[
Collection::crud("billFormat"),
Collection::crud("billPresentationMedia"),
Collection::crud("billingAccount"),
Collection::crud("billingCycleSpecification"),
Collection::crud("financialAccount"),
Collection::crud("partyAccount"),
Collection::crud("settlementAccount"),
Collection::new("hub", &[Operation::Create, Operation::Delete]),
],
);
const BILLING: &str = "billingAccount";
const FINANCIAL: &str = "financialAccount";
const PARTY: &str = "partyAccount";
const SETTLEMENT: &str = "settlementAccount";
const FORMATS: &str = "billFormat";
const MEDIA: &str = "billPresentationMedia";
const CYCLES: &str = "billingCycleSpecification";
#[derive(Debug, Clone)]
pub struct AccountClient {
inner: TmfClient,
}
impl AccountClient {
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!(
BILLING,
read = Account,
create = AccountCreate,
update = AccountUpdate,
list = list_billing_accounts,
stream = stream_billing_accounts,
get = get_billing_account,
new = create_billing_account,
patch = update_billing_account,
delete = delete_billing_account,
doc = "a billing account"
);
resource_ops!(
FINANCIAL,
read = Account,
create = AccountCreate,
update = AccountUpdate,
list = list_financial_accounts,
stream = stream_financial_accounts,
get = get_financial_account,
new = create_financial_account,
patch = update_financial_account,
delete = delete_financial_account,
doc = "a financial account"
);
resource_ops!(
PARTY,
read = Account,
create = AccountCreate,
update = AccountUpdate,
list = list_party_accounts,
stream = stream_party_accounts,
get = get_party_account,
new = create_party_account,
patch = update_party_account,
delete = delete_party_account,
doc = "a party account"
);
resource_ops!(
SETTLEMENT,
read = Account,
create = AccountCreate,
update = AccountUpdate,
list = list_settlement_accounts,
stream = stream_settlement_accounts,
get = get_settlement_account,
new = create_settlement_account,
patch = update_settlement_account,
delete = delete_settlement_account,
doc = "a settlement account"
);
resource_ops!(
FORMATS,
read = BillFormat,
create = BillFormatCreate,
update = BillFormatUpdate,
list = list_bill_formats,
stream = stream_bill_formats,
get = get_bill_format,
new = create_bill_format,
patch = update_bill_format,
delete = delete_bill_format,
doc = "a bill format"
);
resource_ops!(
MEDIA,
read = BillPresentationMedia,
create = BillPresentationMediaCreate,
update = BillPresentationMediaUpdate,
list = list_presentation_media,
stream = stream_presentation_media,
get = get_presentation_medium,
new = create_presentation_medium,
patch = update_presentation_medium,
delete = delete_presentation_medium,
doc = "a bill presentation medium"
);
resource_ops!(
CYCLES,
read = BillingCycleSpecification,
create = BillingCycleSpecificationCreate,
update = BillingCycleSpecificationUpdate,
list = list_billing_cycle_specifications,
stream = stream_billing_cycle_specifications,
get = get_billing_cycle_specification,
new = create_billing_cycle_specification,
patch = update_billing_cycle_specification,
delete = delete_billing_cycle_specification,
doc = "a billing cycle specification"
);
}
impl HubOps for AccountClient {
fn hub_client(&self) -> &TmfClient {
&self.inner
}
}