1use crate::account::{
14 Account, AccountCreate, AccountUpdate, BillFormat, BillFormatCreate, BillFormatUpdate,
15 BillPresentationMedia, BillPresentationMediaCreate, BillPresentationMediaUpdate,
16 BillingCycleSpecification, BillingCycleSpecificationCreate, BillingCycleSpecificationUpdate,
17};
18
19use super::client::TmfClient;
20use super::error::Result;
21use super::hub::HubOps;
22use super::page::{Page, PageRequest, PageStream, paginate};
23use super::patch::Patch;
24use super::query::Query;
25use super::resource_ops;
26use super::transport::Transport;
27use super::{Api, Collection, Operation};
28
29pub const API_PATH: &str = "tmf-api/accountManagement/v5";
31
32pub const SPEC_VERSION: &str = "5.0.0";
38
39pub const API: Api = Api::new(
45 "TMF666",
46 API_PATH,
47 SPEC_VERSION,
48 &[
49 Collection::crud("billFormat"),
50 Collection::crud("billPresentationMedia"),
51 Collection::crud("billingAccount"),
52 Collection::crud("billingCycleSpecification"),
53 Collection::crud("financialAccount"),
54 Collection::crud("partyAccount"),
55 Collection::crud("settlementAccount"),
56 Collection::new("hub", &[Operation::Create, Operation::Delete]),
57 ],
58);
59
60const BILLING: &str = "billingAccount";
61const FINANCIAL: &str = "financialAccount";
62const PARTY: &str = "partyAccount";
63const SETTLEMENT: &str = "settlementAccount";
64const FORMATS: &str = "billFormat";
65const MEDIA: &str = "billPresentationMedia";
66const CYCLES: &str = "billingCycleSpecification";
67
68#[derive(Debug, Clone)]
86pub struct AccountClient {
87 inner: TmfClient,
88}
89
90impl AccountClient {
91 pub fn new(base_url: impl Into<String>, transport: impl Transport + 'static) -> Result<Self> {
99 Ok(Self {
100 inner: TmfClient::new(base_url, transport)?,
101 })
102 }
103
104 pub fn from_host(host: &str, transport: impl Transport + 'static) -> Result<Self> {
112 Self::new(
113 format!("{}/{API_PATH}", host.trim_end_matches('/')),
114 transport,
115 )
116 }
117
118 #[must_use]
120 pub fn inner(&self) -> &TmfClient {
121 &self.inner
122 }
123
124 resource_ops!(
125 BILLING,
126 read = Account,
127 create = AccountCreate,
128 update = AccountUpdate,
129 list = list_billing_accounts,
130 stream = stream_billing_accounts,
131 get = get_billing_account,
132 new = create_billing_account,
133 patch = update_billing_account,
134 delete = delete_billing_account,
135 doc = "a billing account"
136 );
137
138 resource_ops!(
139 FINANCIAL,
140 read = Account,
141 create = AccountCreate,
142 update = AccountUpdate,
143 list = list_financial_accounts,
144 stream = stream_financial_accounts,
145 get = get_financial_account,
146 new = create_financial_account,
147 patch = update_financial_account,
148 delete = delete_financial_account,
149 doc = "a financial account"
150 );
151
152 resource_ops!(
153 PARTY,
154 read = Account,
155 create = AccountCreate,
156 update = AccountUpdate,
157 list = list_party_accounts,
158 stream = stream_party_accounts,
159 get = get_party_account,
160 new = create_party_account,
161 patch = update_party_account,
162 delete = delete_party_account,
163 doc = "a party account"
164 );
165
166 resource_ops!(
167 SETTLEMENT,
168 read = Account,
169 create = AccountCreate,
170 update = AccountUpdate,
171 list = list_settlement_accounts,
172 stream = stream_settlement_accounts,
173 get = get_settlement_account,
174 new = create_settlement_account,
175 patch = update_settlement_account,
176 delete = delete_settlement_account,
177 doc = "a settlement account"
178 );
179
180 resource_ops!(
181 FORMATS,
182 read = BillFormat,
183 create = BillFormatCreate,
184 update = BillFormatUpdate,
185 list = list_bill_formats,
186 stream = stream_bill_formats,
187 get = get_bill_format,
188 new = create_bill_format,
189 patch = update_bill_format,
190 delete = delete_bill_format,
191 doc = "a bill format"
192 );
193
194 resource_ops!(
195 MEDIA,
196 read = BillPresentationMedia,
197 create = BillPresentationMediaCreate,
198 update = BillPresentationMediaUpdate,
199 list = list_presentation_media,
200 stream = stream_presentation_media,
201 get = get_presentation_medium,
202 new = create_presentation_medium,
203 patch = update_presentation_medium,
204 delete = delete_presentation_medium,
205 doc = "a bill presentation medium"
206 );
207
208 resource_ops!(
209 CYCLES,
210 read = BillingCycleSpecification,
211 create = BillingCycleSpecificationCreate,
212 update = BillingCycleSpecificationUpdate,
213 list = list_billing_cycle_specifications,
214 stream = stream_billing_cycle_specifications,
215 get = get_billing_cycle_specification,
216 new = create_billing_cycle_specification,
217 patch = update_billing_cycle_specification,
218 delete = delete_billing_cycle_specification,
219 doc = "a billing cycle specification"
220 );
221}
222
223impl HubOps for AccountClient {
224 fn hub_client(&self) -> &TmfClient {
225 &self.inner
226 }
227}