Skip to main content

hanzo_client/apis/
billing_api.rs

1/*
2 * Hanzo Cloud API
3 *
4 * The Hanzo Cloud API as a customer calls it: every operation under /v1/ except the operator's admin product, relay routes, legacy spellings and capabilities still reached by flag. Tagged by product: the first path segment after /v1/.
5 *
6 * The version of the OpenAPI document: v1
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18/// struct for typed errors of method [`cancel_subscription`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum CancelSubscriptionError {
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`collect_invoice`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum CollectInvoiceError {
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`delete_billing_alerts_by_id`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum DeleteBillingAlertsByIdError {
36    UnknownValue(serde_json::Value),
37}
38
39/// struct for typed errors of method [`delete_billing_methods_by_id`]
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum DeleteBillingMethodsByIdError {
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`delete_billing_portal_methods_by_id`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum DeleteBillingPortalMethodsByIdError {
50    UnknownValue(serde_json::Value),
51}
52
53/// struct for typed errors of method [`get_billing_accounts`]
54#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum GetBillingAccountsError {
57    UnknownValue(serde_json::Value),
58}
59
60/// struct for typed errors of method [`get_billing_accounts_by_id_members`]
61#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum GetBillingAccountsByIdMembersError {
64    UnknownValue(serde_json::Value),
65}
66
67/// struct for typed errors of method [`get_billing_alerts`]
68#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum GetBillingAlertsError {
71    UnknownValue(serde_json::Value),
72}
73
74/// struct for typed errors of method [`get_billing_alerts_authorize`]
75#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum GetBillingAlertsAuthorizeError {
78    UnknownValue(serde_json::Value),
79}
80
81/// struct for typed errors of method [`get_billing_balance`]
82#[derive(Debug, Clone, Serialize, Deserialize)]
83#[serde(untagged)]
84pub enum GetBillingBalanceError {
85    UnknownValue(serde_json::Value),
86}
87
88/// struct for typed errors of method [`get_billing_credit_balance`]
89#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum GetBillingCreditBalanceError {
92    UnknownValue(serde_json::Value),
93}
94
95/// struct for typed errors of method [`get_billing_credit_balance_breakdown`]
96#[derive(Debug, Clone, Serialize, Deserialize)]
97#[serde(untagged)]
98pub enum GetBillingCreditBalanceBreakdownError {
99    UnknownValue(serde_json::Value),
100}
101
102/// struct for typed errors of method [`get_billing_credits`]
103#[derive(Debug, Clone, Serialize, Deserialize)]
104#[serde(untagged)]
105pub enum GetBillingCreditsError {
106    UnknownValue(serde_json::Value),
107}
108
109/// struct for typed errors of method [`get_billing_crypto_deposit_by_id`]
110#[derive(Debug, Clone, Serialize, Deserialize)]
111#[serde(untagged)]
112pub enum GetBillingCryptoDepositByIdError {
113    UnknownValue(serde_json::Value),
114}
115
116/// struct for typed errors of method [`get_billing_crypto_options`]
117#[derive(Debug, Clone, Serialize, Deserialize)]
118#[serde(untagged)]
119pub enum GetBillingCryptoOptionsError {
120    UnknownValue(serde_json::Value),
121}
122
123/// struct for typed errors of method [`get_billing_invoices`]
124#[derive(Debug, Clone, Serialize, Deserialize)]
125#[serde(untagged)]
126pub enum GetBillingInvoicesError {
127    UnknownValue(serde_json::Value),
128}
129
130/// struct for typed errors of method [`get_billing_invoices_by_id_pdf`]
131#[derive(Debug, Clone, Serialize, Deserialize)]
132#[serde(untagged)]
133pub enum GetBillingInvoicesByIdPdfError {
134    UnknownValue(serde_json::Value),
135}
136
137/// struct for typed errors of method [`get_billing_ledger`]
138#[derive(Debug, Clone, Serialize, Deserialize)]
139#[serde(untagged)]
140pub enum GetBillingLedgerError {
141    UnknownValue(serde_json::Value),
142}
143
144/// struct for typed errors of method [`get_billing_methods`]
145#[derive(Debug, Clone, Serialize, Deserialize)]
146#[serde(untagged)]
147pub enum GetBillingMethodsError {
148    UnknownValue(serde_json::Value),
149}
150
151/// struct for typed errors of method [`get_billing_payouts`]
152#[derive(Debug, Clone, Serialize, Deserialize)]
153#[serde(untagged)]
154pub enum GetBillingPayoutsError {
155    UnknownValue(serde_json::Value),
156}
157
158/// struct for typed errors of method [`get_billing_plans`]
159#[derive(Debug, Clone, Serialize, Deserialize)]
160#[serde(untagged)]
161pub enum GetBillingPlansError {
162    UnknownValue(serde_json::Value),
163}
164
165/// struct for typed errors of method [`get_billing_portal_methods`]
166#[derive(Debug, Clone, Serialize, Deserialize)]
167#[serde(untagged)]
168pub enum GetBillingPortalMethodsError {
169    UnknownValue(serde_json::Value),
170}
171
172/// struct for typed errors of method [`get_billing_settings`]
173#[derive(Debug, Clone, Serialize, Deserialize)]
174#[serde(untagged)]
175pub enum GetBillingSettingsError {
176    UnknownValue(serde_json::Value),
177}
178
179/// struct for typed errors of method [`get_billing_subscriptions`]
180#[derive(Debug, Clone, Serialize, Deserialize)]
181#[serde(untagged)]
182pub enum GetBillingSubscriptionsError {
183    UnknownValue(serde_json::Value),
184}
185
186/// struct for typed errors of method [`get_billing_tier`]
187#[derive(Debug, Clone, Serialize, Deserialize)]
188#[serde(untagged)]
189pub enum GetBillingTierError {
190    UnknownValue(serde_json::Value),
191}
192
193/// struct for typed errors of method [`get_billing_transactions`]
194#[derive(Debug, Clone, Serialize, Deserialize)]
195#[serde(untagged)]
196pub enum GetBillingTransactionsError {
197    UnknownValue(serde_json::Value),
198}
199
200/// struct for typed errors of method [`get_billing_usage`]
201#[derive(Debug, Clone, Serialize, Deserialize)]
202#[serde(untagged)]
203pub enum GetBillingUsageError {
204    UnknownValue(serde_json::Value),
205}
206
207/// struct for typed errors of method [`get_billing_usage_accounts`]
208#[derive(Debug, Clone, Serialize, Deserialize)]
209#[serde(untagged)]
210pub enum GetBillingUsageAccountsError {
211    UnknownValue(serde_json::Value),
212}
213
214/// struct for typed errors of method [`get_billing_usage_rollup`]
215#[derive(Debug, Clone, Serialize, Deserialize)]
216#[serde(untagged)]
217pub enum GetBillingUsageRollupError {
218    UnknownValue(serde_json::Value),
219}
220
221/// struct for typed errors of method [`get_billing_wire`]
222#[derive(Debug, Clone, Serialize, Deserialize)]
223#[serde(untagged)]
224pub enum GetBillingWireError {
225    UnknownValue(serde_json::Value),
226}
227
228/// struct for typed errors of method [`get_invoice`]
229#[derive(Debug, Clone, Serialize, Deserialize)]
230#[serde(untagged)]
231pub enum GetInvoiceError {
232    UnknownValue(serde_json::Value),
233}
234
235/// struct for typed errors of method [`issue_invoice`]
236#[derive(Debug, Clone, Serialize, Deserialize)]
237#[serde(untagged)]
238pub enum IssueInvoiceError {
239    UnknownValue(serde_json::Value),
240}
241
242/// struct for typed errors of method [`patch_billing_alerts_by_id`]
243#[derive(Debug, Clone, Serialize, Deserialize)]
244#[serde(untagged)]
245pub enum PatchBillingAlertsByIdError {
246    UnknownValue(serde_json::Value),
247}
248
249/// struct for typed errors of method [`post_billing_alerts`]
250#[derive(Debug, Clone, Serialize, Deserialize)]
251#[serde(untagged)]
252pub enum PostBillingAlertsError {
253    UnknownValue(serde_json::Value),
254}
255
256/// struct for typed errors of method [`post_billing_crypto_deposit`]
257#[derive(Debug, Clone, Serialize, Deserialize)]
258#[serde(untagged)]
259pub enum PostBillingCryptoDepositError {
260    UnknownValue(serde_json::Value),
261}
262
263/// struct for typed errors of method [`post_billing_methods`]
264#[derive(Debug, Clone, Serialize, Deserialize)]
265#[serde(untagged)]
266pub enum PostBillingMethodsError {
267    UnknownValue(serde_json::Value),
268}
269
270/// struct for typed errors of method [`post_billing_mode`]
271#[derive(Debug, Clone, Serialize, Deserialize)]
272#[serde(untagged)]
273pub enum PostBillingModeError {
274    UnknownValue(serde_json::Value),
275}
276
277/// struct for typed errors of method [`post_billing_portal_methods`]
278#[derive(Debug, Clone, Serialize, Deserialize)]
279#[serde(untagged)]
280pub enum PostBillingPortalMethodsError {
281    UnknownValue(serde_json::Value),
282}
283
284/// struct for typed errors of method [`post_billing_recharge_run_all`]
285#[derive(Debug, Clone, Serialize, Deserialize)]
286#[serde(untagged)]
287pub enum PostBillingRechargeRunAllError {
288    UnknownValue(serde_json::Value),
289}
290
291/// struct for typed errors of method [`post_billing_subscribe_card`]
292#[derive(Debug, Clone, Serialize, Deserialize)]
293#[serde(untagged)]
294pub enum PostBillingSubscribeCardError {
295    UnknownValue(serde_json::Value),
296}
297
298/// struct for typed errors of method [`post_billing_topup`]
299#[derive(Debug, Clone, Serialize, Deserialize)]
300#[serde(untagged)]
301pub enum PostBillingTopupError {
302    UnknownValue(serde_json::Value),
303}
304
305/// struct for typed errors of method [`post_billing_topup_token`]
306#[derive(Debug, Clone, Serialize, Deserialize)]
307#[serde(untagged)]
308pub enum PostBillingTopupTokenError {
309    UnknownValue(serde_json::Value),
310}
311
312/// struct for typed errors of method [`raise_invoice`]
313#[derive(Debug, Clone, Serialize, Deserialize)]
314#[serde(untagged)]
315pub enum RaiseInvoiceError {
316    UnknownValue(serde_json::Value),
317}
318
319/// struct for typed errors of method [`reactivate_subscription`]
320#[derive(Debug, Clone, Serialize, Deserialize)]
321#[serde(untagged)]
322pub enum ReactivateSubscriptionError {
323    UnknownValue(serde_json::Value),
324}
325
326/// struct for typed errors of method [`void_invoice`]
327#[derive(Debug, Clone, Serialize, Deserialize)]
328#[serde(untagged)]
329pub enum VoidInvoiceError {
330    UnknownValue(serde_json::Value),
331}
332
333
334/// Ends a subscription.  It cancels at the END OF THE PAID PERIOD by default, because a customer who cancels has already paid for the period they are in and taking it away is taking money for nothing. `atPeriodEnd: false` ends it at once, which is the caller asking for that.  A subscription from another org is not found rather than refused, so an id cannot be probed for existence.  A named handler, not a closure, so zipdoc can lift this prose into the registry.
335pub async fn cancel_subscription(configuration: &configuration::Configuration, id: &str, subscription_ref: models::SubscriptionRef) -> Result<models::Subscription, Error<CancelSubscriptionError>> {
336    // add a prefix to parameters to efficiently prevent name collisions
337    let p_id = id;
338    let p_subscription_ref = subscription_ref;
339
340    let uri_str = format!("{}/v1/billing/subscriptions/{id}/cancel", configuration.base_path, id=crate::apis::urlencode(p_id));
341    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
342
343    if let Some(ref user_agent) = configuration.user_agent {
344        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
345    }
346    if let Some(ref token) = configuration.bearer_access_token {
347        req_builder = req_builder.bearer_auth(token.to_owned());
348    };
349    req_builder = req_builder.json(&p_subscription_ref);
350
351    let req = req_builder.build()?;
352    let resp = configuration.client.execute(req).await?;
353
354    let status = resp.status();
355    let content_type = resp
356        .headers()
357        .get("content-type")
358        .and_then(|v| v.to_str().ok())
359        .unwrap_or("application/octet-stream");
360    let content_type = super::ContentType::from(content_type);
361
362    if !status.is_client_error() && !status.is_server_error() {
363        let content = resp.text().await?;
364        match content_type {
365            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
366            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Subscription`"))),
367            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Subscription`")))),
368        }
369    } else {
370        let content = resp.text().await?;
371        let entity: Option<CancelSubscriptionError> = serde_json::from_str(&content).ok();
372        Err(Error::ResponseError(ResponseContent { status, content, entity }))
373    }
374}
375
376/// Collects an issued invoice: credit grants first, then prepaid balance, then the card on file — the same waterfall the dunning workflow runs.  A DECLINE IS NOT AN ERROR. It answers with paid=false, a reason, and the invoice still open, because a declined collection is a normal business outcome that must remain retryable — and because sealing it as a failure would wedge dunning behind a replayed decline. Only a successful collection is sealed, so a retry of a paid invoice replays the receipt instead of charging again.  A named handler, not a closure, so zipdoc can lift this prose into the registry.
377pub async fn collect_invoice(configuration: &configuration::Configuration, id: &str) -> Result<models::Collected, Error<CollectInvoiceError>> {
378    // add a prefix to parameters to efficiently prevent name collisions
379    let p_id = id;
380
381    let uri_str = format!("{}/v1/billing/invoices/{id}/collect", configuration.base_path, id=crate::apis::urlencode(p_id));
382    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
383
384    if let Some(ref user_agent) = configuration.user_agent {
385        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
386    }
387    if let Some(ref token) = configuration.bearer_access_token {
388        req_builder = req_builder.bearer_auth(token.to_owned());
389    };
390
391    let req = req_builder.build()?;
392    let resp = configuration.client.execute(req).await?;
393
394    let status = resp.status();
395    let content_type = resp
396        .headers()
397        .get("content-type")
398        .and_then(|v| v.to_str().ok())
399        .unwrap_or("application/octet-stream");
400    let content_type = super::ContentType::from(content_type);
401
402    if !status.is_client_error() && !status.is_server_error() {
403        let content = resp.text().await?;
404        match content_type {
405            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
406            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Collected`"))),
407            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Collected`")))),
408        }
409    } else {
410        let content = resp.text().await?;
411        let entity: Option<CollectInvoiceError> = serde_json::from_str(&content).ok();
412        Err(Error::ResponseError(ResponseContent { status, content, entity }))
413    }
414}
415
416/// Removes one of the caller's spend caps and answers 204.  Removing a cap RAISES what the org may spend, so it takes the same authority setting one does. The caps that remain still bind: this drops one, never the whole policy.
417pub async fn delete_billing_alerts_by_id(configuration: &configuration::Configuration, id: &str) -> Result<(), Error<DeleteBillingAlertsByIdError>> {
418    // add a prefix to parameters to efficiently prevent name collisions
419    let p_id = id;
420
421    let uri_str = format!("{}/v1/billing/alerts/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
422    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
423
424    if let Some(ref user_agent) = configuration.user_agent {
425        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
426    }
427    if let Some(ref token) = configuration.bearer_access_token {
428        req_builder = req_builder.bearer_auth(token.to_owned());
429    };
430
431    let req = req_builder.build()?;
432    let resp = configuration.client.execute(req).await?;
433
434    let status = resp.status();
435
436    if !status.is_client_error() && !status.is_server_error() {
437        Ok(())
438    } else {
439        let content = resp.text().await?;
440        let entity: Option<DeleteBillingAlertsByIdError> = serde_json::from_str(&content).ok();
441        Err(Error::ResponseError(ResponseContent { status, content, entity }))
442    }
443}
444
445/// Removes one card or account the caller has saved.  It detaches only the CALLER'S own — the wallet this request bills from, resolved server-side — so an id belonging to another customer of the same org is not something this operation can reach. A platform or service caller detaches on the subject's behalf, and that authority is decided HERE, where the credential is, and travels as a value: authority decided twice is authority that eventually disagrees with itself.  The card is vaulted at the processor, so what goes is our token for it.
446pub async fn delete_billing_methods_by_id(configuration: &configuration::Configuration, id: &str) -> Result<models::Detachment, Error<DeleteBillingMethodsByIdError>> {
447    // add a prefix to parameters to efficiently prevent name collisions
448    let p_id = id;
449
450    let uri_str = format!("{}/v1/billing/methods/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
451    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
452
453    if let Some(ref user_agent) = configuration.user_agent {
454        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
455    }
456    if let Some(ref token) = configuration.bearer_access_token {
457        req_builder = req_builder.bearer_auth(token.to_owned());
458    };
459
460    let req = req_builder.build()?;
461    let resp = configuration.client.execute(req).await?;
462
463    let status = resp.status();
464    let content_type = resp
465        .headers()
466        .get("content-type")
467        .and_then(|v| v.to_str().ok())
468        .unwrap_or("application/octet-stream");
469    let content_type = super::ContentType::from(content_type);
470
471    if !status.is_client_error() && !status.is_server_error() {
472        let content = resp.text().await?;
473        match content_type {
474            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
475            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Detachment`"))),
476            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Detachment`")))),
477        }
478    } else {
479        let content = resp.text().await?;
480        let entity: Option<DeleteBillingMethodsByIdError> = serde_json::from_str(&content).ok();
481        Err(Error::ResponseError(ResponseContent { status, content, entity }))
482    }
483}
484
485/// DetachPortalMethod is DetachMethod at the address a hosted checkout addresses it by. One set of rows, two spellings: a card detached at either is gone from both, because there is one store behind them.
486pub async fn delete_billing_portal_methods_by_id(configuration: &configuration::Configuration, id: &str) -> Result<models::Detachment, Error<DeleteBillingPortalMethodsByIdError>> {
487    // add a prefix to parameters to efficiently prevent name collisions
488    let p_id = id;
489
490    let uri_str = format!("{}/v1/billing/portal/methods/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
491    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
492
493    if let Some(ref user_agent) = configuration.user_agent {
494        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
495    }
496    if let Some(ref token) = configuration.bearer_access_token {
497        req_builder = req_builder.bearer_auth(token.to_owned());
498    };
499
500    let req = req_builder.build()?;
501    let resp = configuration.client.execute(req).await?;
502
503    let status = resp.status();
504    let content_type = resp
505        .headers()
506        .get("content-type")
507        .and_then(|v| v.to_str().ok())
508        .unwrap_or("application/octet-stream");
509    let content_type = super::ContentType::from(content_type);
510
511    if !status.is_client_error() && !status.is_server_error() {
512        let content = resp.text().await?;
513        match content_type {
514            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
515            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Detachment`"))),
516            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Detachment`")))),
517        }
518    } else {
519        let content = resp.text().await?;
520        let entity: Option<DeleteBillingPortalMethodsByIdError> = serde_json::from_str(&content).ok();
521        Err(Error::ResponseError(ResponseContent { status, content, entity }))
522    }
523}
524
525/// Answers the caller's billing accounts: the org itself, its currency, when it was opened, and the caller's own standing in it.  The standing is the caller's, resolved from the validated principal here and sent to the store rather than looked up there — the membership roster is IAM's and commerce keeps none, so a callee that answered \"what role is this\" would be inventing it. An anonymous read gets the account with no role rather than an implied membership.  Scoped to the caller's own org, which is the whole tenancy story: there is no org field on the wire and none on the input.  A named handler, not a closure, so zipdoc can lift this prose into the registry.
526pub async fn get_billing_accounts(configuration: &configuration::Configuration, ) -> Result<Vec<models::BillingAccount>, Error<GetBillingAccountsError>> {
527
528    let uri_str = format!("{}/v1/billing/accounts", configuration.base_path);
529    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
530
531    if let Some(ref user_agent) = configuration.user_agent {
532        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
533    }
534    if let Some(ref token) = configuration.bearer_access_token {
535        req_builder = req_builder.bearer_auth(token.to_owned());
536    };
537
538    let req = req_builder.build()?;
539    let resp = configuration.client.execute(req).await?;
540
541    let status = resp.status();
542    let content_type = resp
543        .headers()
544        .get("content-type")
545        .and_then(|v| v.to_str().ok())
546        .unwrap_or("application/octet-stream");
547    let content_type = super::ContentType::from(content_type);
548
549    if !status.is_client_error() && !status.is_server_error() {
550        let content = resp.text().await?;
551        match content_type {
552            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
553            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::BillingAccount&gt;`"))),
554            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::BillingAccount&gt;`")))),
555        }
556    } else {
557        let content = resp.text().await?;
558        let entity: Option<GetBillingAccountsError> = serde_json::from_str(&content).ok();
559        Err(Error::ResponseError(ResponseContent { status, content, entity }))
560    }
561}
562
563/// Answers one billing account's roster.  commerce stores no roster — that is IAM's — so the only member it can name is the caller, and that is what comes back. What it does enforce is that the account named in the path is the caller's own: a foreign id is 403, not an empty list, because \"no members\" and \"not your account\" are different answers.  A named handler, not a closure, so zipdoc can lift this prose into the registry.
564pub async fn get_billing_accounts_by_id_members(configuration: &configuration::Configuration, id: &str) -> Result<Vec<models::Holder>, Error<GetBillingAccountsByIdMembersError>> {
565    // add a prefix to parameters to efficiently prevent name collisions
566    let p_id = id;
567
568    let uri_str = format!("{}/v1/billing/accounts/{id}/members", configuration.base_path, id=crate::apis::urlencode(p_id));
569    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
570
571    if let Some(ref user_agent) = configuration.user_agent {
572        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
573    }
574    if let Some(ref token) = configuration.bearer_access_token {
575        req_builder = req_builder.bearer_auth(token.to_owned());
576    };
577
578    let req = req_builder.build()?;
579    let resp = configuration.client.execute(req).await?;
580
581    let status = resp.status();
582    let content_type = resp
583        .headers()
584        .get("content-type")
585        .and_then(|v| v.to_str().ok())
586        .unwrap_or("application/octet-stream");
587    let content_type = super::ContentType::from(content_type);
588
589    if !status.is_client_error() && !status.is_server_error() {
590        let content = resp.text().await?;
591        match content_type {
592            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
593            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::Holder&gt;`"))),
594            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::Holder&gt;`")))),
595        }
596    } else {
597        let content = resp.text().await?;
598        let entity: Option<GetBillingAccountsByIdMembersError> = serde_json::from_str(&content).ok();
599        Err(Error::ResponseError(ResponseContent { status, content, entity }))
600    }
601}
602
603/// Lists this org's spend caps: the ceiling, its scope, whether it enforces, and how much of it has been spent this period.  `periodSpentCents`, `over` and `warn` are ABSENT rather than zero when the spend could not be read, because \"nothing spent\" and \"spend unknown\" are different answers and a customer acting on the first when the second is true would be reading a ceiling that is not there. The policy row is reported either way.  The period is the UTC calendar month and `resetsAt` is when the count starts again, so a surface can say \"resets on\" without a second call.  A named handler, not a closure, so zipdoc can lift this prose into the registry.
604pub async fn get_billing_alerts(configuration: &configuration::Configuration, ) -> Result<Vec<models::Alert>, Error<GetBillingAlertsError>> {
605
606    let uri_str = format!("{}/v1/billing/alerts", configuration.base_path);
607    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
608
609    if let Some(ref user_agent) = configuration.user_agent {
610        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
611    }
612    if let Some(ref token) = configuration.bearer_access_token {
613        req_builder = req_builder.bearer_auth(token.to_owned());
614    };
615
616    let req = req_builder.build()?;
617    let resp = configuration.client.execute(req).await?;
618
619    let status = resp.status();
620    let content_type = resp
621        .headers()
622        .get("content-type")
623        .and_then(|v| v.to_str().ok())
624        .unwrap_or("application/octet-stream");
625    let content_type = super::ContentType::from(content_type);
626
627    if !status.is_client_error() && !status.is_server_error() {
628        let content = resp.text().await?;
629        match content_type {
630            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
631            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::Alert&gt;`"))),
632            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::Alert&gt;`")))),
633        }
634    } else {
635        let content = resp.text().await?;
636        let entity: Option<GetBillingAlertsError> = serde_json::from_str(&content).ok();
637        Err(Error::ResponseError(ResponseContent { status, content, entity }))
638    }
639}
640
641/// Answers whether one proposed spend fits inside this org's caps.  It is the per-request verdict the metering edge consumes before every priced call, and its caller is a SERVICE rather than a person: a service token plus the gateway-pinned org, with no user behind it. So this admits that principal where the CRUD beside it does not.  Every covering row is evaluated, most-restrictive-wins, and the tightest one is what `capCents`, `spentCents` and `reason` describe. Soft rows never deny; nor does a project-scoped enforcing row whose project axis the caller could not establish — `pv=1` is how a caller states that it did, and an unproven claim must not be able to refuse traffic.  A named handler, not a closure, so zipdoc can lift this prose into the registry.
642pub async fn get_billing_alerts_authorize(configuration: &configuration::Configuration, project: Option<&str>, service: Option<&str>, amount: Option<&str>, pv: Option<&str>) -> Result<models::CapVerdict, Error<GetBillingAlertsAuthorizeError>> {
643    // add a prefix to parameters to efficiently prevent name collisions
644    let p_project = project;
645    let p_service = service;
646    let p_amount = amount;
647    let p_pv = pv;
648
649    let uri_str = format!("{}/v1/billing/alerts/authorize", configuration.base_path);
650    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
651
652    if let Some(ref param_value) = p_project {
653        req_builder = req_builder.query(&[("project", &param_value.to_string())]);
654    }
655    if let Some(ref param_value) = p_service {
656        req_builder = req_builder.query(&[("service", &param_value.to_string())]);
657    }
658    if let Some(ref param_value) = p_amount {
659        req_builder = req_builder.query(&[("amount", &param_value.to_string())]);
660    }
661    if let Some(ref param_value) = p_pv {
662        req_builder = req_builder.query(&[("pv", &param_value.to_string())]);
663    }
664    if let Some(ref user_agent) = configuration.user_agent {
665        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
666    }
667    if let Some(ref token) = configuration.bearer_access_token {
668        req_builder = req_builder.bearer_auth(token.to_owned());
669    };
670
671    let req = req_builder.build()?;
672    let resp = configuration.client.execute(req).await?;
673
674    let status = resp.status();
675    let content_type = resp
676        .headers()
677        .get("content-type")
678        .and_then(|v| v.to_str().ok())
679        .unwrap_or("application/octet-stream");
680    let content_type = super::ContentType::from(content_type);
681
682    if !status.is_client_error() && !status.is_server_error() {
683        let content = resp.text().await?;
684        match content_type {
685            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
686            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CapVerdict`"))),
687            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CapVerdict`")))),
688        }
689    } else {
690        let content = resp.text().await?;
691        let entity: Option<GetBillingAlertsAuthorizeError> = serde_json::from_str(&content).ok();
692        Err(Error::ResponseError(ResponseContent { status, content, entity }))
693    }
694}
695
696/// Answers the spendable prepaid balance of the wallet this caller bills from — the same wallet the AI prepaid gate reads before admitting a paid request, the edge meter debits, and a top-up credits.  The wallet is an ADDRESS, not an org: `account` echoes the key resolved within the ledger — the org's shared pool for a tenant org, a personal account for a member of the shared signup org. The echo is the point. A browser could only GUESS its own payer by decoding its own token, and a guess that disagrees with the server is how money lands in an account the gate never reads.  `balance`, `holds` and `available` are whole USD cents, ROUNDED from the ledger's exact 18-decimal value. On the co-resident ledger `holds` is 0 and `available` equals `balance`: the gate's reservations live in its own pod and are never posted, so the settled balance IS the spendable one.  The ledger is the caller's own org, taken from the VALIDATED IAM owner claim and never from a client header. No validated principal is 401 — with one exception, the trusted in-process service token the AI gate itself presents, which reads the gateway-pinned org and nothing it could name. A balance that cannot be READ is 502, never 0: unknown is not broke.
697pub async fn get_billing_balance(configuration: &configuration::Configuration, ) -> Result<(), Error<GetBillingBalanceError>> {
698
699    let uri_str = format!("{}/v1/billing/balance", configuration.base_path);
700    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
701
702    if let Some(ref user_agent) = configuration.user_agent {
703        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
704    }
705    if let Some(ref token) = configuration.bearer_access_token {
706        req_builder = req_builder.bearer_auth(token.to_owned());
707    };
708
709    let req = req_builder.build()?;
710    let resp = configuration.client.execute(req).await?;
711
712    let status = resp.status();
713
714    if !status.is_client_error() && !status.is_server_error() {
715        Ok(())
716    } else {
717        let content = resp.text().await?;
718        let entity: Option<GetBillingBalanceError> = serde_json::from_str(&content).ok();
719        Err(Error::ResponseError(ResponseContent { status, content, entity }))
720    }
721}
722
723/// Answers what the caller can spend right now, one entry per currency.  Only ACTIVE grants count: a voided, exhausted or lapsed grant contributes nothing, which is why this number can be smaller than the grant list suggests and why the two reads exist separately. It is credit, not prepaid balance — /v1/billing/balance is the wallet, and the two are added by the gate, never by a reader.  A named handler, not a closure, so zipdoc can lift this prose into the registry.
724pub async fn get_billing_credit_balance(configuration: &configuration::Configuration, ) -> Result<models::CreditBalance, Error<GetBillingCreditBalanceError>> {
725
726    let uri_str = format!("{}/v1/billing/credit-balance", configuration.base_path);
727    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
728
729    if let Some(ref user_agent) = configuration.user_agent {
730        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
731    }
732    if let Some(ref token) = configuration.bearer_access_token {
733        req_builder = req_builder.bearer_auth(token.to_owned());
734    };
735
736    let req = req_builder.build()?;
737    let resp = configuration.client.execute(req).await?;
738
739    let status = resp.status();
740    let content_type = resp
741        .headers()
742        .get("content-type")
743        .and_then(|v| v.to_str().ok())
744        .unwrap_or("application/octet-stream");
745    let content_type = super::ContentType::from(content_type);
746
747    if !status.is_client_error() && !status.is_server_error() {
748        let content = resp.text().await?;
749        match content_type {
750            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
751            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreditBalance`"))),
752            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CreditBalance`")))),
753        }
754    } else {
755        let content = resp.text().await?;
756        let entity: Option<GetBillingCreditBalanceError> = serde_json::from_str(&content).ok();
757        Err(Error::ResponseError(ResponseContent { status, content, entity }))
758    }
759}
760
761/// Answers that same spendable credit split by grant tag, with the earliest expiry under each and the total across all of them.  The split is the point: it is how trial credit is told apart from bought credit, which is what a surface asks before it decides whether to spend any. An unregistered address answers 404 and a caller reads that as \"no credit\", so this being served is the difference between a customer with a trial grant being offered their trial and being told they have none.  A named handler, not a closure, so zipdoc can lift this prose into the registry.
762pub async fn get_billing_credit_balance_breakdown(configuration: &configuration::Configuration, ) -> Result<serde_json::Value, Error<GetBillingCreditBalanceBreakdownError>> {
763
764    let uri_str = format!("{}/v1/billing/credit-balance/breakdown", configuration.base_path);
765    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
766
767    if let Some(ref user_agent) = configuration.user_agent {
768        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
769    }
770    if let Some(ref token) = configuration.bearer_access_token {
771        req_builder = req_builder.bearer_auth(token.to_owned());
772    };
773
774    let req = req_builder.build()?;
775    let resp = configuration.client.execute(req).await?;
776
777    let status = resp.status();
778    let content_type = resp
779        .headers()
780        .get("content-type")
781        .and_then(|v| v.to_str().ok())
782        .unwrap_or("application/octet-stream");
783    let content_type = super::ContentType::from(content_type);
784
785    if !status.is_client_error() && !status.is_server_error() {
786        let content = resp.text().await?;
787        match content_type {
788            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
789            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
790            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
791        }
792    } else {
793        let content = resp.text().await?;
794        let entity: Option<GetBillingCreditBalanceBreakdownError> = serde_json::from_str(&content).ok();
795        Err(Error::ResponseError(ResponseContent { status, content, entity }))
796    }
797}
798
799/// Lists the caller's credit grants — every one of them, spent and lapsed and voided included.  That is deliberate and it is what makes the list useful: a grant list is a LEDGER, and one that hid its spent rows could not be reconciled against a burn-down. What is spendable right now is the sibling read, /v1/billing/ credit-balance, and the two are different questions.  Scoped to the caller's own wallet, resolved server-side.  A named handler, not a closure, so zipdoc can lift this prose into the registry.
800pub async fn get_billing_credits(configuration: &configuration::Configuration, ) -> Result<models::CreditGrants, Error<GetBillingCreditsError>> {
801
802    let uri_str = format!("{}/v1/billing/credits", configuration.base_path);
803    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
804
805    if let Some(ref user_agent) = configuration.user_agent {
806        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
807    }
808    if let Some(ref token) = configuration.bearer_access_token {
809        req_builder = req_builder.bearer_auth(token.to_owned());
810    };
811
812    let req = req_builder.build()?;
813    let resp = configuration.client.execute(req).await?;
814
815    let status = resp.status();
816    let content_type = resp
817        .headers()
818        .get("content-type")
819        .and_then(|v| v.to_str().ok())
820        .unwrap_or("application/octet-stream");
821    let content_type = super::ContentType::from(content_type);
822
823    if !status.is_client_error() && !status.is_server_error() {
824        let content = resp.text().await?;
825        match content_type {
826            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
827            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreditGrants`"))),
828            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CreditGrants`")))),
829        }
830    } else {
831        let content = resp.text().await?;
832        let entity: Option<GetBillingCreditsError> = serde_json::from_str(&content).ok();
833        Err(Error::ResponseError(ResponseContent { status, content, entity }))
834    }
835}
836
837/// Reads one of the caller's own deposit intents back — pending, confirming, or succeeded.  An intent belonging to another payer answers 404, exactly as an id that names nothing, so a guessed id cannot confirm that somebody else's deposit exists.  A named handler, not a closure, so zipdoc can lift this prose into the registry.
838pub async fn get_billing_crypto_deposit_by_id(configuration: &configuration::Configuration, id: &str) -> Result<models::CryptoDeposit, Error<GetBillingCryptoDepositByIdError>> {
839    // add a prefix to parameters to efficiently prevent name collisions
840    let p_id = id;
841
842    let uri_str = format!("{}/v1/billing/crypto/deposit/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
843    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
844
845    if let Some(ref user_agent) = configuration.user_agent {
846        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
847    }
848    if let Some(ref token) = configuration.bearer_access_token {
849        req_builder = req_builder.bearer_auth(token.to_owned());
850    };
851
852    let req = req_builder.build()?;
853    let resp = configuration.client.execute(req).await?;
854
855    let status = resp.status();
856    let content_type = resp
857        .headers()
858        .get("content-type")
859        .and_then(|v| v.to_str().ok())
860        .unwrap_or("application/octet-stream");
861    let content_type = super::ContentType::from(content_type);
862
863    if !status.is_client_error() && !status.is_server_error() {
864        let content = resp.text().await?;
865        match content_type {
866            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
867            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CryptoDeposit`"))),
868            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CryptoDeposit`")))),
869        }
870    } else {
871        let content = resp.text().await?;
872        let entity: Option<GetBillingCryptoDepositByIdError> = serde_json::from_str(&content).ok();
873        Err(Error::ResponseError(ResponseContent { status, content, entity }))
874    }
875}
876
877/// Answers which chains and tokens the crypto rail accepts — what an asset picker renders.  It is the intersection of two live facts rather than a configured list: an asset appears only if something is WATCHING it and the custody processor supports it. An address nobody watches credits nobody, so offering one would take a customer's money and lose it. A rail with nothing armed answers 503, not an empty menu — \"no rail\" and \"no assets\" are different, and only one of them means try again later.  A named handler, not a closure, so zipdoc can lift this prose into the registry.
878pub async fn get_billing_crypto_options(configuration: &configuration::Configuration, ) -> Result<models::CryptoOptions, Error<GetBillingCryptoOptionsError>> {
879
880    let uri_str = format!("{}/v1/billing/crypto/options", configuration.base_path);
881    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
882
883    if let Some(ref user_agent) = configuration.user_agent {
884        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
885    }
886    if let Some(ref token) = configuration.bearer_access_token {
887        req_builder = req_builder.bearer_auth(token.to_owned());
888    };
889
890    let req = req_builder.build()?;
891    let resp = configuration.client.execute(req).await?;
892
893    let status = resp.status();
894    let content_type = resp
895        .headers()
896        .get("content-type")
897        .and_then(|v| v.to_str().ok())
898        .unwrap_or("application/octet-stream");
899    let content_type = super::ContentType::from(content_type);
900
901    if !status.is_client_error() && !status.is_server_error() {
902        let content = resp.text().await?;
903        match content_type {
904            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
905            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CryptoOptions`"))),
906            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CryptoOptions`")))),
907        }
908    } else {
909        let content = resp.text().await?;
910        let entity: Option<GetBillingCryptoOptionsError> = serde_json::from_str(&content).ok();
911        Err(Error::ResponseError(ResponseContent { status, content, entity }))
912    }
913}
914
915/// Lists the caller's invoices, newest first, with the count beside them.  It is scoped to the caller's own billing subject — the wallet this request bills from, resolved server-side — so a query cannot widen it to another customer of the same org. An org with no invoices is an empty list, not a refusal.  A named handler, not a closure, so zipdoc can lift this prose into the registry.
916pub async fn get_billing_invoices(configuration: &configuration::Configuration, ) -> Result<models::Invoices, Error<GetBillingInvoicesError>> {
917
918    let uri_str = format!("{}/v1/billing/invoices", configuration.base_path);
919    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
920
921    if let Some(ref user_agent) = configuration.user_agent {
922        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
923    }
924    if let Some(ref token) = configuration.bearer_access_token {
925        req_builder = req_builder.bearer_auth(token.to_owned());
926    };
927
928    let req = req_builder.build()?;
929    let resp = configuration.client.execute(req).await?;
930
931    let status = resp.status();
932    let content_type = resp
933        .headers()
934        .get("content-type")
935        .and_then(|v| v.to_str().ok())
936        .unwrap_or("application/octet-stream");
937    let content_type = super::ContentType::from(content_type);
938
939    if !status.is_client_error() && !status.is_server_error() {
940        let content = resp.text().await?;
941        match content_type {
942            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
943            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Invoices`"))),
944            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Invoices`")))),
945        }
946    } else {
947        let content = resp.text().await?;
948        let entity: Option<GetBillingInvoicesError> = serde_json::from_str(&content).ok();
949        Err(Error::ResponseError(ResponseContent { status, content, entity }))
950    }
951}
952
953/// Answers the invoice as an attachment — `application/pdf` under a Content-Disposition naming the invoice number — rather than as a JSON value, which is why this one route is untyped where its five siblings are typed: a PDF is bytes with a filename, and the two headers are the whole contract.  The render is a PURE function of the invoice: one page, no timestamps and no random ids, so the same invoice renders the same bytes however often it is asked for and a retry after a dropped connection costs a re-render and nothing else.  The invoice is read from the caller's own org, taken from the VALIDATED IAM owner claim and never from a client header, and the lookup is scoped at the storage layer — so an id belonging to another customer resolves to nothing and answers 404 rather than being found and then refused.
954pub async fn get_billing_invoices_by_id_pdf(configuration: &configuration::Configuration, id: &str) -> Result<(), Error<GetBillingInvoicesByIdPdfError>> {
955    // add a prefix to parameters to efficiently prevent name collisions
956    let p_id = id;
957
958    let uri_str = format!("{}/v1/billing/invoices/{id}/pdf", configuration.base_path, id=crate::apis::urlencode(p_id));
959    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
960
961    if let Some(ref user_agent) = configuration.user_agent {
962        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
963    }
964    if let Some(ref token) = configuration.bearer_access_token {
965        req_builder = req_builder.bearer_auth(token.to_owned());
966    };
967
968    let req = req_builder.build()?;
969    let resp = configuration.client.execute(req).await?;
970
971    let status = resp.status();
972
973    if !status.is_client_error() && !status.is_server_error() {
974        Ok(())
975    } else {
976        let content = resp.text().await?;
977        let entity: Option<GetBillingInvoicesByIdPdfError> = serde_json::from_str(&content).ok();
978        Err(Error::ResponseError(ResponseContent { status, content, entity }))
979    }
980}
981
982/// Answers the org's own postings inside `range=`, each as a signed entry: a DEPOSIT CREDITS the wallet (positive, account `credits:<org>`) and every other posting DEBITS it (negative, account `usage:<org>`), described by its notes or its tags. The sign is the posting's own meaning, read through ONE vocabulary shared with the ledger that wrote it — a reader with its own spelling for `deposit` rendered a customer's grant as a charge.  This is the closest projection of the truth. The org's double-entry postings are the source of record — balanced, only ever appended, one file per org — and this lane is that list, wider than either half of it: the deposits are the grants /v1/billing/credits lists and the debits are the spend /v1/billing/usage rolls up. It answers 503 where this deployment runs no ledger, rather than reporting an empty wallet.  A row whose timestamp will not parse is KEPT rather than dropped — a malformed date must show up in a money list, not vanish from it. `balanceCents` is omitted: these are MOVEMENTS, and the standing balance is /v1/billing/balance.  Cents are ROUNDED from the ledger's exact 18-decimal USD. Scoped to the caller's own org, where the org's ledger file is the tenant boundary; 401 without a validated principal.
983pub async fn get_billing_ledger(configuration: &configuration::Configuration, range: Option<&str>) -> Result<Vec<models::FinanceLedgerEntry>, Error<GetBillingLedgerError>> {
984    // add a prefix to parameters to efficiently prevent name collisions
985    let p_range = range;
986
987    let uri_str = format!("{}/v1/billing/ledger", configuration.base_path);
988    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
989
990    if let Some(ref param_value) = p_range {
991        req_builder = req_builder.query(&[("range", &param_value.to_string())]);
992    }
993    if let Some(ref user_agent) = configuration.user_agent {
994        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
995    }
996    if let Some(ref token) = configuration.bearer_access_token {
997        req_builder = req_builder.bearer_auth(token.to_owned());
998    };
999
1000    let req = req_builder.build()?;
1001    let resp = configuration.client.execute(req).await?;
1002
1003    let status = resp.status();
1004    let content_type = resp
1005        .headers()
1006        .get("content-type")
1007        .and_then(|v| v.to_str().ok())
1008        .unwrap_or("application/octet-stream");
1009    let content_type = super::ContentType::from(content_type);
1010
1011    if !status.is_client_error() && !status.is_server_error() {
1012        let content = resp.text().await?;
1013        match content_type {
1014            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1015            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::FinanceLedgerEntry&gt;`"))),
1016            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::FinanceLedgerEntry&gt;`")))),
1017        }
1018    } else {
1019        let content = resp.text().await?;
1020        let entity: Option<GetBillingLedgerError> = serde_json::from_str(&content).ok();
1021        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1022    }
1023}
1024
1025/// Answers every payment method the caller has saved, newest first.  A saved method is a card or account VAULTED at the processor: what is stored here is the processor's token for it plus the last four digits and the expiry a customer recognises it by, never a card number.  The list is the caller's OWN — the wallet this request bills from, resolved server-side — so a query cannot widen it to another customer of the same org.  `/v1/billing/portal/methods` answers the same list under the name a hosted checkout addresses it by. One set of rows, two spellings; a card added at either is present at both.  A store that cannot be read answers an EMPTY LIST rather than a failure: the saved-cards panel renders empty instead of breaking the page around it.
1026pub async fn get_billing_methods(configuration: &configuration::Configuration, ) -> Result<(), Error<GetBillingMethodsError>> {
1027
1028    let uri_str = format!("{}/v1/billing/methods", configuration.base_path);
1029    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1030
1031    if let Some(ref user_agent) = configuration.user_agent {
1032        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1033    }
1034    if let Some(ref token) = configuration.bearer_access_token {
1035        req_builder = req_builder.bearer_auth(token.to_owned());
1036    };
1037
1038    let req = req_builder.build()?;
1039    let resp = configuration.client.execute(req).await?;
1040
1041    let status = resp.status();
1042
1043    if !status.is_client_error() && !status.is_server_error() {
1044        Ok(())
1045    } else {
1046        let content = resp.text().await?;
1047        let entity: Option<GetBillingMethodsError> = serde_json::from_str(&content).ok();
1048        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1049    }
1050}
1051
1052/// Answers the org's outbound payouts, newest first — amount, destination, status, and the failure reason where one applies.  A payout is ORG-scoped rather than subject-scoped, so there is nothing to pin beyond the tenant the caller already is, and no query can widen it.  A named handler, not a closure, so zipdoc can lift this prose into the registry.
1053pub async fn get_billing_payouts(configuration: &configuration::Configuration, ) -> Result<Vec<models::Payout>, Error<GetBillingPayoutsError>> {
1054
1055    let uri_str = format!("{}/v1/billing/payouts", configuration.base_path);
1056    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1057
1058    if let Some(ref user_agent) = configuration.user_agent {
1059        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1060    }
1061    if let Some(ref token) = configuration.bearer_access_token {
1062        req_builder = req_builder.bearer_auth(token.to_owned());
1063    };
1064
1065    let req = req_builder.build()?;
1066    let resp = configuration.client.execute(req).await?;
1067
1068    let status = resp.status();
1069    let content_type = resp
1070        .headers()
1071        .get("content-type")
1072        .and_then(|v| v.to_str().ok())
1073        .unwrap_or("application/octet-stream");
1074    let content_type = super::ContentType::from(content_type);
1075
1076    if !status.is_client_error() && !status.is_server_error() {
1077        let content = resp.text().await?;
1078        match content_type {
1079            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1080            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::Payout&gt;`"))),
1081            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::Payout&gt;`")))),
1082        }
1083    } else {
1084        let content = resp.text().await?;
1085        let entity: Option<GetBillingPayoutsError> = serde_json::from_str(&content).ok();
1086        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1087    }
1088}
1089
1090/// Answers every plan on sale — its price, what it includes, and the limits it carries — optionally narrowed to one `?category=`.  The prices are what the CHECKOUT will charge: any active promotion is applied before they leave the store, so a reader never applies a discount a second time and a quote can never disagree with the sale.  It is the public catalog and needs no tenant: this is what anyone may buy.
1091pub async fn get_billing_plans(configuration: &configuration::Configuration, ) -> Result<(), Error<GetBillingPlansError>> {
1092
1093    let uri_str = format!("{}/v1/billing/plans", configuration.base_path);
1094    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1095
1096    if let Some(ref user_agent) = configuration.user_agent {
1097        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1098    }
1099    if let Some(ref token) = configuration.bearer_access_token {
1100        req_builder = req_builder.bearer_auth(token.to_owned());
1101    };
1102
1103    let req = req_builder.build()?;
1104    let resp = configuration.client.execute(req).await?;
1105
1106    let status = resp.status();
1107
1108    if !status.is_client_error() && !status.is_server_error() {
1109        Ok(())
1110    } else {
1111        let content = resp.text().await?;
1112        let entity: Option<GetBillingPlansError> = serde_json::from_str(&content).ok();
1113        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1114    }
1115}
1116
1117/// Answers every payment method the caller has saved, newest first.  A saved method is a card or account VAULTED at the processor: what is stored here is the processor's token for it plus the last four digits and the expiry a customer recognises it by, never a card number.  The list is the caller's OWN — the wallet this request bills from, resolved server-side — so a query cannot widen it to another customer of the same org.  `/v1/billing/portal/methods` answers the same list under the name a hosted checkout addresses it by. One set of rows, two spellings; a card added at either is present at both.  A store that cannot be read answers an EMPTY LIST rather than a failure: the saved-cards panel renders empty instead of breaking the page around it.
1118pub async fn get_billing_portal_methods(configuration: &configuration::Configuration, ) -> Result<(), Error<GetBillingPortalMethodsError>> {
1119
1120    let uri_str = format!("{}/v1/billing/portal/methods", configuration.base_path);
1121    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1122
1123    if let Some(ref user_agent) = configuration.user_agent {
1124        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1125    }
1126    if let Some(ref token) = configuration.bearer_access_token {
1127        req_builder = req_builder.bearer_auth(token.to_owned());
1128    };
1129
1130    let req = req_builder.build()?;
1131    let resp = configuration.client.execute(req).await?;
1132
1133    let status = resp.status();
1134
1135    if !status.is_client_error() && !status.is_server_error() {
1136        Ok(())
1137    } else {
1138        let content = resp.text().await?;
1139        let entity: Option<GetBillingPortalMethodsError> = serde_json::from_str(&content).ok();
1140        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1141    }
1142}
1143
1144/// Answers the PUBLIC half of this org's processor configuration — the ids a browser needs to tokenize a card, and the environment it must tokenize against.  It carries no secret: an application id is published to every checkout page by design. What matters is that it names the SAME processor account the charge will be made on, because a card vaulted against one account and charged against another is a card that saves and then cannot be used.  A named handler, not a closure, so zipdoc can lift this prose into the registry.
1145pub async fn get_billing_settings(configuration: &configuration::Configuration, ) -> Result<models::PaymentConfig, Error<GetBillingSettingsError>> {
1146
1147    let uri_str = format!("{}/v1/billing/settings", configuration.base_path);
1148    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1149
1150    if let Some(ref user_agent) = configuration.user_agent {
1151        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1152    }
1153    if let Some(ref token) = configuration.bearer_access_token {
1154        req_builder = req_builder.bearer_auth(token.to_owned());
1155    };
1156
1157    let req = req_builder.build()?;
1158    let resp = configuration.client.execute(req).await?;
1159
1160    let status = resp.status();
1161    let content_type = resp
1162        .headers()
1163        .get("content-type")
1164        .and_then(|v| v.to_str().ok())
1165        .unwrap_or("application/octet-stream");
1166    let content_type = super::ContentType::from(content_type);
1167
1168    if !status.is_client_error() && !status.is_server_error() {
1169        let content = resp.text().await?;
1170        match content_type {
1171            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1172            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaymentConfig`"))),
1173            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PaymentConfig`")))),
1174        }
1175    } else {
1176        let content = resp.text().await?;
1177        let entity: Option<GetBillingSettingsError> = serde_json::from_str(&content).ok();
1178        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1179    }
1180}
1181
1182/// Lists the plans the caller holds, with the count beside them.  It is scoped to the caller's own org, so a query cannot widen it to another customer's. An org on nothing is an empty list, not a refusal — being on no plan is an answer.  A named handler, not a closure, so zipdoc can lift this prose into the registry.
1183pub async fn get_billing_subscriptions(configuration: &configuration::Configuration, ) -> Result<models::Subscriptions, Error<GetBillingSubscriptionsError>> {
1184
1185    let uri_str = format!("{}/v1/billing/subscriptions", configuration.base_path);
1186    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1187
1188    if let Some(ref user_agent) = configuration.user_agent {
1189        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1190    }
1191    if let Some(ref token) = configuration.bearer_access_token {
1192        req_builder = req_builder.bearer_auth(token.to_owned());
1193    };
1194
1195    let req = req_builder.build()?;
1196    let resp = configuration.client.execute(req).await?;
1197
1198    let status = resp.status();
1199    let content_type = resp
1200        .headers()
1201        .get("content-type")
1202        .and_then(|v| v.to_str().ok())
1203        .unwrap_or("application/octet-stream");
1204    let content_type = super::ContentType::from(content_type);
1205
1206    if !status.is_client_error() && !status.is_server_error() {
1207        let content = resp.text().await?;
1208        match content_type {
1209            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1210            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Subscriptions`"))),
1211            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Subscriptions`")))),
1212        }
1213    } else {
1214        let content = resp.text().await?;
1215        let entity: Option<GetBillingSubscriptionsError> = serde_json::from_str(&content).ok();
1216        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1217    }
1218}
1219
1220/// Answers which tier the caller is on, what it allows, and what is left to spend.  `effectiveAvailable` is the ONLY figure to compare against zero. The others are its parts — prepaid money, granted credits and the daily term are three sources of one spend, not three balances to add up a second time.  A tier that cannot be READ is an error, never Free. The router in front of the models maps any non-2xx to Free, so answering Free from a question nobody could answer would pin every paying customer to the most restrictive row with nothing anywhere to find.  A named handler, not a closure, so zipdoc can lift this prose into the registry.
1221pub async fn get_billing_tier(configuration: &configuration::Configuration, ) -> Result<models::Tier, Error<GetBillingTierError>> {
1222
1223    let uri_str = format!("{}/v1/billing/tier", configuration.base_path);
1224    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1225
1226    if let Some(ref user_agent) = configuration.user_agent {
1227        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1228    }
1229    if let Some(ref token) = configuration.bearer_access_token {
1230        req_builder = req_builder.bearer_auth(token.to_owned());
1231    };
1232
1233    let req = req_builder.build()?;
1234    let resp = configuration.client.execute(req).await?;
1235
1236    let status = resp.status();
1237    let content_type = resp
1238        .headers()
1239        .get("content-type")
1240        .and_then(|v| v.to_str().ok())
1241        .unwrap_or("application/octet-stream");
1242    let content_type = super::ContentType::from(content_type);
1243
1244    if !status.is_client_error() && !status.is_server_error() {
1245        let content = resp.text().await?;
1246        match content_type {
1247            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1248            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Tier`"))),
1249            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Tier`")))),
1250        }
1251    } else {
1252        let content = resp.text().await?;
1253        let entity: Option<GetBillingTierError> = serde_json::from_str(&content).ok();
1254        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1255    }
1256}
1257
1258/// Answers one page of the caller's own ledger, newest first: what moved, how much, when, and what it was tagged with.  `count` is the size of the WHOLE history rather than of the page, which is how a reader knows there is more to ask for, and `user` echoes the wallet the page was read for — the same subject the spend gate debits, so a customer can see which account answered rather than guessing from their own token.  A named handler, not a closure, so zipdoc can lift this prose into the registry.
1259pub async fn get_billing_transactions(configuration: &configuration::Configuration, currency: Option<&str>, limit: Option<&str>, offset: Option<&str>) -> Result<models::Transactions, Error<GetBillingTransactionsError>> {
1260    // add a prefix to parameters to efficiently prevent name collisions
1261    let p_currency = currency;
1262    let p_limit = limit;
1263    let p_offset = offset;
1264
1265    let uri_str = format!("{}/v1/billing/transactions", configuration.base_path);
1266    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1267
1268    if let Some(ref param_value) = p_currency {
1269        req_builder = req_builder.query(&[("currency", &param_value.to_string())]);
1270    }
1271    if let Some(ref param_value) = p_limit {
1272        req_builder = req_builder.query(&[("limit", &param_value.to_string())]);
1273    }
1274    if let Some(ref param_value) = p_offset {
1275        req_builder = req_builder.query(&[("offset", &param_value.to_string())]);
1276    }
1277    if let Some(ref user_agent) = configuration.user_agent {
1278        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1279    }
1280    if let Some(ref token) = configuration.bearer_access_token {
1281        req_builder = req_builder.bearer_auth(token.to_owned());
1282    };
1283
1284    let req = req_builder.build()?;
1285    let resp = configuration.client.execute(req).await?;
1286
1287    let status = resp.status();
1288    let content_type = resp
1289        .headers()
1290        .get("content-type")
1291        .and_then(|v| v.to_str().ok())
1292        .unwrap_or("application/octet-stream");
1293    let content_type = super::ContentType::from(content_type);
1294
1295    if !status.is_client_error() && !status.is_server_error() {
1296        let content = resp.text().await?;
1297        match content_type {
1298            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1299            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Transactions`"))),
1300            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Transactions`")))),
1301        }
1302    } else {
1303        let content = resp.text().await?;
1304        let entity: Option<GetBillingTransactionsError> = serde_json::from_str(&content).ok();
1305        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1306    }
1307}
1308
1309/// Answers one row per BILLED call against the caller's org — transaction id, amount, timestamp and the metered unit. This is the raw charged ledger, not a rollup.  Each row is stamped with a canonical `metadata.product` derived from what the meter persisted: `agent` becomes agents, `provisioning` becomes the provisioned kind, a token-metered row becomes inference, anything else keeps its metering surface. The ledger has no product field of its own, so this read is where that dimension is made real — from the SAME charged rows, never a second meter. A row that already carries its own product WINS, so the derivation stops the day the meter records one.  `product=<id>` filters to one product server-side. `groupBy=product` reduces to `{product,requests,amountCents}` rollups instead of rows.  `amount` is whole USD cents, ROUNDED; `decimal` beside it is the SAME debit exact, as an 18-decimal USD string. Sum `decimal`. A page of sub-cent token calls totals correctly there and totals ZERO in `amount` — that difference is real money.  Scoped to the caller's own org's books, where the org's ledger file IS the tenant boundary; no client-supplied subject is ever forwarded. 401 without a validated principal. The co-resident read returns the 2000 most recent debits, newest first; `start` and `end` narrow the window only on the split-deploy upstream.
1310pub async fn get_billing_usage(configuration: &configuration::Configuration, ) -> Result<(), Error<GetBillingUsageError>> {
1311
1312    let uri_str = format!("{}/v1/billing/usage", configuration.base_path);
1313    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1314
1315    if let Some(ref user_agent) = configuration.user_agent {
1316        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1317    }
1318    if let Some(ref token) = configuration.bearer_access_token {
1319        req_builder = req_builder.bearer_auth(token.to_owned());
1320    };
1321
1322    let req = req_builder.build()?;
1323    let resp = configuration.client.execute(req).await?;
1324
1325    let status = resp.status();
1326
1327    if !status.is_client_error() && !status.is_server_error() {
1328        Ok(())
1329    } else {
1330        let content = resp.text().await?;
1331        let entity: Option<GetBillingUsageError> = serde_json::from_str(&content).ok();
1332        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1333    }
1334}
1335
1336/// Answers per-account totals for the linked provider accounts the gateway ROUTED this caller's traffic through — requests, prompt and completion tokens, recorded cost — plus their honest sum.  This is the one read in the billing namespace scoped to the PERSON, not the org. Rows are keyed on (validated org, validated user), so a caller sees the accounts THEY linked and never a colleague's, even inside one org — everything else under /v1/billing is org-wide. Neither key is ever read from the request body or the query.  It is a ROUTING counter, not the money ledger. `costCents` is 0 for an account billed by its own subscription, where the plan pays the provider directly, so these totals do not reconcile against what the org was charged. /v1/billing/usage is the charged ledger.  401 without a validated principal. Where the linked-account plane is not resident the answer is an honest 501 — never an empty breakdown, which would read as no usage.
1337pub async fn get_billing_usage_accounts(configuration: &configuration::Configuration, ) -> Result<models::Accounts, Error<GetBillingUsageAccountsError>> {
1338
1339    let uri_str = format!("{}/v1/billing/usage/accounts", configuration.base_path);
1340    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1341
1342    if let Some(ref user_agent) = configuration.user_agent {
1343        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1344    }
1345    if let Some(ref token) = configuration.bearer_access_token {
1346        req_builder = req_builder.bearer_auth(token.to_owned());
1347    };
1348
1349    let req = req_builder.build()?;
1350    let resp = configuration.client.execute(req).await?;
1351
1352    let status = resp.status();
1353    let content_type = resp
1354        .headers()
1355        .get("content-type")
1356        .and_then(|v| v.to_str().ok())
1357        .unwrap_or("application/octet-stream");
1358    let content_type = super::ContentType::from(content_type);
1359
1360    if !status.is_client_error() && !status.is_server_error() {
1361        let content = resp.text().await?;
1362        match content_type {
1363            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1364            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Accounts`"))),
1365            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Accounts`")))),
1366        }
1367    } else {
1368        let content = resp.text().await?;
1369        let entity: Option<GetBillingUsageAccountsError> = serde_json::from_str(&content).ok();
1370        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1371    }
1372}
1373
1374/// Answers the caller's month: what their plan includes, what has been consumed against it, and the wallet beside it.  The two blocks are SEPARATE monies and are never added. One is usage a plan granted; the other is prepaid credit bought with a card. Their sum is not a number anyone holds, and a reader that formed it would be inventing a balance.  A named handler, not a closure, so zipdoc can lift this prose into the registry.
1375pub async fn get_billing_usage_rollup(configuration: &configuration::Configuration, ) -> Result<models::Rollup, Error<GetBillingUsageRollupError>> {
1376
1377    let uri_str = format!("{}/v1/billing/usage/rollup", configuration.base_path);
1378    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1379
1380    if let Some(ref user_agent) = configuration.user_agent {
1381        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1382    }
1383    if let Some(ref token) = configuration.bearer_access_token {
1384        req_builder = req_builder.bearer_auth(token.to_owned());
1385    };
1386
1387    let req = req_builder.build()?;
1388    let resp = configuration.client.execute(req).await?;
1389
1390    let status = resp.status();
1391    let content_type = resp
1392        .headers()
1393        .get("content-type")
1394        .and_then(|v| v.to_str().ok())
1395        .unwrap_or("application/octet-stream");
1396    let content_type = super::ContentType::from(content_type);
1397
1398    if !status.is_client_error() && !status.is_server_error() {
1399        let content = resp.text().await?;
1400        match content_type {
1401            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1402            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Rollup`"))),
1403            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Rollup`")))),
1404        }
1405    } else {
1406        let content = resp.text().await?;
1407        let entity: Option<GetBillingUsageRollupError> = serde_json::from_str(&content).ok();
1408        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1409    }
1410}
1411
1412/// Answers where to send a wire top-up: the receiving bank details, with the caller's own payment reference.  The account is the SERVING BRAND'S — resolved from the host the customer is paying on, so paying on one brand never shows another's bank — and the reference carries the caller's billing key, which is how an arriving wire names who it credits. Nothing mints here; a receipt is settled by an operator once the bank confirms it.  It is all-or-nothing: no configured account is 503 rather than a partial form, because nobody can wire to three fields out of five.  A named handler, not a closure, so zipdoc can lift this prose into the registry.
1413pub async fn get_billing_wire(configuration: &configuration::Configuration, ) -> Result<models::WireInstructions, Error<GetBillingWireError>> {
1414
1415    let uri_str = format!("{}/v1/billing/wire", configuration.base_path);
1416    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1417
1418    if let Some(ref user_agent) = configuration.user_agent {
1419        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1420    }
1421    if let Some(ref token) = configuration.bearer_access_token {
1422        req_builder = req_builder.bearer_auth(token.to_owned());
1423    };
1424
1425    let req = req_builder.build()?;
1426    let resp = configuration.client.execute(req).await?;
1427
1428    let status = resp.status();
1429    let content_type = resp
1430        .headers()
1431        .get("content-type")
1432        .and_then(|v| v.to_str().ok())
1433        .unwrap_or("application/octet-stream");
1434    let content_type = super::ContentType::from(content_type);
1435
1436    if !status.is_client_error() && !status.is_server_error() {
1437        let content = resp.text().await?;
1438        match content_type {
1439            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1440            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::WireInstructions`"))),
1441            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::WireInstructions`")))),
1442        }
1443    } else {
1444        let content = resp.text().await?;
1445        let entity: Option<GetBillingWireError> = serde_json::from_str(&content).ok();
1446        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1447    }
1448}
1449
1450/// Reads one invoice out of the caller's org.  The org scopes the read by construction — the store is namespaced to it — so an id belonging to another tenant is not found rather than found and then filtered.  A named handler, not a closure, so zipdoc can lift this prose into the registry.
1451pub async fn get_invoice(configuration: &configuration::Configuration, id: &str) -> Result<models::Invoice, Error<GetInvoiceError>> {
1452    // add a prefix to parameters to efficiently prevent name collisions
1453    let p_id = id;
1454
1455    let uri_str = format!("{}/v1/billing/invoices/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
1456    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1457
1458    if let Some(ref user_agent) = configuration.user_agent {
1459        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1460    }
1461    if let Some(ref token) = configuration.bearer_access_token {
1462        req_builder = req_builder.bearer_auth(token.to_owned());
1463    };
1464
1465    let req = req_builder.build()?;
1466    let resp = configuration.client.execute(req).await?;
1467
1468    let status = resp.status();
1469    let content_type = resp
1470        .headers()
1471        .get("content-type")
1472        .and_then(|v| v.to_str().ok())
1473        .unwrap_or("application/octet-stream");
1474    let content_type = super::ContentType::from(content_type);
1475
1476    if !status.is_client_error() && !status.is_server_error() {
1477        let content = resp.text().await?;
1478        match content_type {
1479            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1480            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Invoice`"))),
1481            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Invoice`")))),
1482        }
1483    } else {
1484        let content = resp.text().await?;
1485        let entity: Option<GetInvoiceError> = serde_json::from_str(&content).ok();
1486        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1487    }
1488}
1489
1490/// Issues a draft invoice: moves it to OPEN, assigns its number, and makes it collectible.  Only a draft can be issued. An invoice already open, paid or void is refused with the state machine's own reason rather than being silently re-issued, which would mint a second number for one debt.  A named handler, not a closure, so zipdoc can lift this prose into the registry.
1491pub async fn issue_invoice(configuration: &configuration::Configuration, id: &str) -> Result<models::Invoice, Error<IssueInvoiceError>> {
1492    // add a prefix to parameters to efficiently prevent name collisions
1493    let p_id = id;
1494
1495    let uri_str = format!("{}/v1/billing/invoices/{id}/issue", configuration.base_path, id=crate::apis::urlencode(p_id));
1496    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1497
1498    if let Some(ref user_agent) = configuration.user_agent {
1499        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1500    }
1501    if let Some(ref token) = configuration.bearer_access_token {
1502        req_builder = req_builder.bearer_auth(token.to_owned());
1503    };
1504
1505    let req = req_builder.build()?;
1506    let resp = configuration.client.execute(req).await?;
1507
1508    let status = resp.status();
1509    let content_type = resp
1510        .headers()
1511        .get("content-type")
1512        .and_then(|v| v.to_str().ok())
1513        .unwrap_or("application/octet-stream");
1514    let content_type = super::ContentType::from(content_type);
1515
1516    if !status.is_client_error() && !status.is_server_error() {
1517        let content = resp.text().await?;
1518        match content_type {
1519            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1520            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Invoice`"))),
1521            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Invoice`")))),
1522        }
1523    } else {
1524        let content = resp.text().await?;
1525        let entity: Option<IssueInvoiceError> = serde_json::from_str(&content).ok();
1526        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1527    }
1528}
1529
1530/// Changes one spend cap: raise or lower the ceiling, flip enforcement, retune the rate limit.  Only the fields the body carries move. Every mutable field is optional, and an absent one is PRESERVED rather than reset — so a change that flips enforcement cannot silently wipe the threshold it enforces.  A cap belonging to another org is a 404, not a 403: a guessed id must not become an oracle for what anyone else holds.  A named handler, not a closure, so zipdoc can lift this prose into the registry.
1531pub async fn patch_billing_alerts_by_id(configuration: &configuration::Configuration, id: &str, alert_patch: models::AlertPatch) -> Result<models::Alert, Error<PatchBillingAlertsByIdError>> {
1532    // add a prefix to parameters to efficiently prevent name collisions
1533    let p_id = id;
1534    let p_alert_patch = alert_patch;
1535
1536    let uri_str = format!("{}/v1/billing/alerts/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
1537    let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
1538
1539    if let Some(ref user_agent) = configuration.user_agent {
1540        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1541    }
1542    if let Some(ref token) = configuration.bearer_access_token {
1543        req_builder = req_builder.bearer_auth(token.to_owned());
1544    };
1545    req_builder = req_builder.json(&p_alert_patch);
1546
1547    let req = req_builder.build()?;
1548    let resp = configuration.client.execute(req).await?;
1549
1550    let status = resp.status();
1551    let content_type = resp
1552        .headers()
1553        .get("content-type")
1554        .and_then(|v| v.to_str().ok())
1555        .unwrap_or("application/octet-stream");
1556    let content_type = super::ContentType::from(content_type);
1557
1558    if !status.is_client_error() && !status.is_server_error() {
1559        let content = resp.text().await?;
1560        match content_type {
1561            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1562            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Alert`"))),
1563            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Alert`")))),
1564        }
1565    } else {
1566        let content = resp.text().await?;
1567        let entity: Option<PatchBillingAlertsByIdError> = serde_json::from_str(&content).ok();
1568        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1569    }
1570}
1571
1572/// Opens a spend cap on the caller's own org.  At least one limit must mean something: a threshold above zero (a spend cap) or a requests-per-minute above zero (a rate limit). A row that bounds neither is refused rather than stored, because a ceiling nothing measures against is a ceiling a customer believes in and does not have.  The cap is keyed on the caller's own billing subject, resolved server-side — the SAME key the verdict looks it up under, which is what makes enforcement bind rather than merely record.  A named handler, not a closure, so zipdoc can lift this prose into the registry.
1573pub async fn post_billing_alerts(configuration: &configuration::Configuration, alert_spec: models::AlertSpec) -> Result<models::Alert, Error<PostBillingAlertsError>> {
1574    // add a prefix to parameters to efficiently prevent name collisions
1575    let p_alert_spec = alert_spec;
1576
1577    let uri_str = format!("{}/v1/billing/alerts", configuration.base_path);
1578    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1579
1580    if let Some(ref user_agent) = configuration.user_agent {
1581        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1582    }
1583    if let Some(ref token) = configuration.bearer_access_token {
1584        req_builder = req_builder.bearer_auth(token.to_owned());
1585    };
1586    req_builder = req_builder.json(&p_alert_spec);
1587
1588    let req = req_builder.build()?;
1589    let resp = configuration.client.execute(req).await?;
1590
1591    let status = resp.status();
1592    let content_type = resp
1593        .headers()
1594        .get("content-type")
1595        .and_then(|v| v.to_str().ok())
1596        .unwrap_or("application/octet-stream");
1597    let content_type = super::ContentType::from(content_type);
1598
1599    if !status.is_client_error() && !status.is_server_error() {
1600        let content = resp.text().await?;
1601        match content_type {
1602            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1603            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Alert`"))),
1604            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Alert`")))),
1605        }
1606    } else {
1607        let content = resp.text().await?;
1608        let entity: Option<PostBillingAlertsError> = serde_json::from_str(&content).ok();
1609        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1610    }
1611}
1612
1613/// Issues a deposit address the caller can send crypto to, on the asset they ask for.  The address credits the CALLER'S own wallet and nobody else's: the payer is the validated principal, never a body value. Asking again reuses the caller's open intent rather than minting a second address, so a refresh cannot spray key generations — and a payer who sent to the address they saw earlier is still credited.  No balance moves here. The chain watcher credits on real confirmations, so what comes back is an address and a status, not a receipt.  An asset this rail cannot mint on is 400 — ask for another. A rail that is shut for that asset is 503 — nothing sent now can be credited.  A named handler, not a closure, so zipdoc can lift this prose into the registry.
1614pub async fn post_billing_crypto_deposit(configuration: &configuration::Configuration, crypto_asset: models::CryptoAsset) -> Result<models::CryptoDeposit, Error<PostBillingCryptoDepositError>> {
1615    // add a prefix to parameters to efficiently prevent name collisions
1616    let p_crypto_asset = crypto_asset;
1617
1618    let uri_str = format!("{}/v1/billing/crypto/deposit", configuration.base_path);
1619    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1620
1621    if let Some(ref user_agent) = configuration.user_agent {
1622        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1623    }
1624    if let Some(ref token) = configuration.bearer_access_token {
1625        req_builder = req_builder.bearer_auth(token.to_owned());
1626    };
1627    req_builder = req_builder.json(&p_crypto_asset);
1628
1629    let req = req_builder.build()?;
1630    let resp = configuration.client.execute(req).await?;
1631
1632    let status = resp.status();
1633    let content_type = resp
1634        .headers()
1635        .get("content-type")
1636        .and_then(|v| v.to_str().ok())
1637        .unwrap_or("application/octet-stream");
1638    let content_type = super::ContentType::from(content_type);
1639
1640    if !status.is_client_error() && !status.is_server_error() {
1641        let content = resp.text().await?;
1642        match content_type {
1643            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1644            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CryptoDeposit`"))),
1645            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CryptoDeposit`")))),
1646        }
1647    } else {
1648        let content = resp.text().await?;
1649        let entity: Option<PostBillingCryptoDepositError> = serde_json::from_str(&content).ok();
1650        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1651    }
1652}
1653
1654/// Vaults the instrument at the processor and stores the row.  A saved method is a card or account VAULTED at the processor: what is stored here is the processor's token for it plus the last four digits and the expiry a customer recognises it by, never a card number.  The list is the caller's OWN — the wallet this request bills from, resolved server-side — so a query cannot widen it to another customer of the same org.  `/v1/billing/portal/methods` answers the same list under the name a hosted checkout addresses it by. One set of rows, two spellings; a card added at either is present at both.  Saving a card ALREADY on file answers with the row that already holds it rather than stacking a duplicate — 200 for that, 201 for a genuinely new row, so a client can tell which happened. A card the processor declines is 402 and nothing is stored.
1655pub async fn post_billing_methods(configuration: &configuration::Configuration, ) -> Result<(), Error<PostBillingMethodsError>> {
1656
1657    let uri_str = format!("{}/v1/billing/methods", configuration.base_path);
1658    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1659
1660    if let Some(ref user_agent) = configuration.user_agent {
1661        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1662    }
1663    if let Some(ref token) = configuration.bearer_access_token {
1664        req_builder = req_builder.bearer_auth(token.to_owned());
1665    };
1666
1667    let req = req_builder.build()?;
1668    let resp = configuration.client.execute(req).await?;
1669
1670    let status = resp.status();
1671
1672    if !status.is_client_error() && !status.is_server_error() {
1673        Ok(())
1674    } else {
1675        let content = resp.text().await?;
1676        let entity: Option<PostBillingMethodsError> = serde_json::from_str(&content).ok();
1677        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1678    }
1679}
1680
1681/// Moves this org between sandbox money and real money.  It decides whether a charge hits a real card, so it is the one posture change that is not self-service: the platform bar, never an org owner, because an org that could put itself in test mode could take priced work for free.  A named handler, not a closure, so zipdoc can lift this prose into the registry.
1682pub async fn post_billing_mode(configuration: &configuration::Configuration, mode_in: models::ModeIn) -> Result<models::Mode, Error<PostBillingModeError>> {
1683    // add a prefix to parameters to efficiently prevent name collisions
1684    let p_mode_in = mode_in;
1685
1686    let uri_str = format!("{}/v1/billing/mode", configuration.base_path);
1687    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1688
1689    if let Some(ref user_agent) = configuration.user_agent {
1690        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1691    }
1692    if let Some(ref token) = configuration.bearer_access_token {
1693        req_builder = req_builder.bearer_auth(token.to_owned());
1694    };
1695    req_builder = req_builder.json(&p_mode_in);
1696
1697    let req = req_builder.build()?;
1698    let resp = configuration.client.execute(req).await?;
1699
1700    let status = resp.status();
1701    let content_type = resp
1702        .headers()
1703        .get("content-type")
1704        .and_then(|v| v.to_str().ok())
1705        .unwrap_or("application/octet-stream");
1706    let content_type = super::ContentType::from(content_type);
1707
1708    if !status.is_client_error() && !status.is_server_error() {
1709        let content = resp.text().await?;
1710        match content_type {
1711            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1712            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Mode`"))),
1713            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Mode`")))),
1714        }
1715    } else {
1716        let content = resp.text().await?;
1717        let entity: Option<PostBillingModeError> = serde_json::from_str(&content).ok();
1718        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1719    }
1720}
1721
1722/// Vaults the instrument at the processor and stores the row.  A saved method is a card or account VAULTED at the processor: what is stored here is the processor's token for it plus the last four digits and the expiry a customer recognises it by, never a card number.  The list is the caller's OWN — the wallet this request bills from, resolved server-side — so a query cannot widen it to another customer of the same org.  `/v1/billing/portal/methods` answers the same list under the name a hosted checkout addresses it by. One set of rows, two spellings; a card added at either is present at both.  Saving a card ALREADY on file answers with the row that already holds it rather than stacking a duplicate — 200 for that, 201 for a genuinely new row, so a client can tell which happened. A card the processor declines is 402 and nothing is stored.
1723pub async fn post_billing_portal_methods(configuration: &configuration::Configuration, ) -> Result<(), Error<PostBillingPortalMethodsError>> {
1724
1725    let uri_str = format!("{}/v1/billing/portal/methods", configuration.base_path);
1726    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1727
1728    if let Some(ref user_agent) = configuration.user_agent {
1729        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1730    }
1731    if let Some(ref token) = configuration.bearer_access_token {
1732        req_builder = req_builder.bearer_auth(token.to_owned());
1733    };
1734
1735    let req = req_builder.build()?;
1736    let resp = configuration.client.execute(req).await?;
1737
1738    let status = resp.status();
1739
1740    if !status.is_client_error() && !status.is_server_error() {
1741        Ok(())
1742    } else {
1743        let content = resp.text().await?;
1744        let entity: Option<PostBillingPortalMethodsError> = serde_json::from_str(&content).ok();
1745        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1746    }
1747}
1748
1749/// Sweeps every org's auto-recharge and answers what it did.  PLATFORM AUTHORITY ONLY. It charges saved cards across every tenant, so an org owner reaching it could sweep-charge the estate; a caller without it is refused before anything is charged.  The answer explains a sweep that charged nobody as readily as one that charged: it names how many orgs were considered and how many needed charging, with a row each.
1750pub async fn post_billing_recharge_run_all(configuration: &configuration::Configuration, ) -> Result<models::Recharge, Error<PostBillingRechargeRunAllError>> {
1751
1752    let uri_str = format!("{}/v1/billing/recharge/run-all", configuration.base_path);
1753    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1754
1755    if let Some(ref user_agent) = configuration.user_agent {
1756        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1757    }
1758    if let Some(ref token) = configuration.bearer_access_token {
1759        req_builder = req_builder.bearer_auth(token.to_owned());
1760    };
1761
1762    let req = req_builder.build()?;
1763    let resp = configuration.client.execute(req).await?;
1764
1765    let status = resp.status();
1766    let content_type = resp
1767        .headers()
1768        .get("content-type")
1769        .and_then(|v| v.to_str().ok())
1770        .unwrap_or("application/octet-stream");
1771    let content_type = super::ContentType::from(content_type);
1772
1773    if !status.is_client_error() && !status.is_server_error() {
1774        let content = resp.text().await?;
1775        match content_type {
1776            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1777            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Recharge`"))),
1778            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Recharge`")))),
1779        }
1780    } else {
1781        let content = resp.text().await?;
1782        let entity: Option<PostBillingRechargeRunAllError> = serde_json::from_str(&content).ok();
1783        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1784    }
1785}
1786
1787/// Vaults the card (or reuses one already on file), charges the plan's FIRST period at the catalog price, and opens the subscription — one act, all of it server-side.  There is NO AMOUNT in the request. `level` picks which of the plan's published prices to buy at — an index, never a number — so what the card is charged is decided by the catalog and underpaying cannot be expressed.  A fresh sale answers 201 with the receipt. An identical retry answers 200 with the FIRST sale's body, byte for byte, so a client cannot read a replay as a second subscription having been opened. A caller already on a paid plan is 409 rather than charged again.
1788pub async fn post_billing_subscribe_card(configuration: &configuration::Configuration, ) -> Result<(), Error<PostBillingSubscribeCardError>> {
1789
1790    let uri_str = format!("{}/v1/billing/subscribe/card", configuration.base_path);
1791    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1792
1793    if let Some(ref user_agent) = configuration.user_agent {
1794        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1795    }
1796    if let Some(ref token) = configuration.bearer_access_token {
1797        req_builder = req_builder.bearer_auth(token.to_owned());
1798    };
1799
1800    let req = req_builder.build()?;
1801    let resp = configuration.client.execute(req).await?;
1802
1803    let status = resp.status();
1804
1805    if !status.is_client_error() && !status.is_server_error() {
1806        Ok(())
1807    } else {
1808        let content = resp.text().await?;
1809        let entity: Option<PostBillingSubscribeCardError> = serde_json::from_str(&content).ok();
1810        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1811    }
1812}
1813
1814/// Charges a card the caller already saved and credits the balance. Same receipt and the same retry safety as the token endpoint; the only difference is which card, so a caller topping up from a saved method never re-enters one.
1815pub async fn post_billing_topup(configuration: &configuration::Configuration, topup_in: models::TopupIn, x_idempotency_key: Option<&str>) -> Result<models::Charged, Error<PostBillingTopupError>> {
1816    // add a prefix to parameters to efficiently prevent name collisions
1817    let p_topup_in = topup_in;
1818    let p_x_idempotency_key = x_idempotency_key;
1819
1820    let uri_str = format!("{}/v1/billing/topup", configuration.base_path);
1821    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1822
1823    if let Some(ref user_agent) = configuration.user_agent {
1824        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1825    }
1826    if let Some(param_value) = p_x_idempotency_key {
1827        req_builder = req_builder.header("X-Idempotency-Key", param_value.to_string());
1828    }
1829    if let Some(ref token) = configuration.bearer_access_token {
1830        req_builder = req_builder.bearer_auth(token.to_owned());
1831    };
1832    req_builder = req_builder.json(&p_topup_in);
1833
1834    let req = req_builder.build()?;
1835    let resp = configuration.client.execute(req).await?;
1836
1837    let status = resp.status();
1838    let content_type = resp
1839        .headers()
1840        .get("content-type")
1841        .and_then(|v| v.to_str().ok())
1842        .unwrap_or("application/octet-stream");
1843    let content_type = super::ContentType::from(content_type);
1844
1845    if !status.is_client_error() && !status.is_server_error() {
1846        let content = resp.text().await?;
1847        match content_type {
1848            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1849            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Charged`"))),
1850            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Charged`")))),
1851        }
1852    } else {
1853        let content = resp.text().await?;
1854        let entity: Option<PostBillingTopupError> = serde_json::from_str(&content).ok();
1855        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1856    }
1857}
1858
1859/// Charges a single-use card token and credits the caller's balance.  The token comes from the payment form and is vaulted as part of the charge, so no card number reaches this service and none is stored here. The receipt names the ledger entry, the new balance, and the PROCESSOR's own reference — which is the only field that proves money moved at the gateway rather than only in our ledger.  Retry-safe on X-Idempotency-Key: the same key settles one charge and returns the first receipt.
1860pub async fn post_billing_topup_token(configuration: &configuration::Configuration, topup_in: models::TopupIn, x_idempotency_key: Option<&str>) -> Result<models::Charged, Error<PostBillingTopupTokenError>> {
1861    // add a prefix to parameters to efficiently prevent name collisions
1862    let p_topup_in = topup_in;
1863    let p_x_idempotency_key = x_idempotency_key;
1864
1865    let uri_str = format!("{}/v1/billing/topup/token", configuration.base_path);
1866    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1867
1868    if let Some(ref user_agent) = configuration.user_agent {
1869        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1870    }
1871    if let Some(param_value) = p_x_idempotency_key {
1872        req_builder = req_builder.header("X-Idempotency-Key", param_value.to_string());
1873    }
1874    if let Some(ref token) = configuration.bearer_access_token {
1875        req_builder = req_builder.bearer_auth(token.to_owned());
1876    };
1877    req_builder = req_builder.json(&p_topup_in);
1878
1879    let req = req_builder.build()?;
1880    let resp = configuration.client.execute(req).await?;
1881
1882    let status = resp.status();
1883    let content_type = resp
1884        .headers()
1885        .get("content-type")
1886        .and_then(|v| v.to_str().ok())
1887        .unwrap_or("application/octet-stream");
1888    let content_type = super::ContentType::from(content_type);
1889
1890    if !status.is_client_error() && !status.is_server_error() {
1891        let content = resp.text().await?;
1892        match content_type {
1893            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1894            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Charged`"))),
1895            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Charged`")))),
1896        }
1897    } else {
1898        let content = resp.text().await?;
1899        let entity: Option<PostBillingTopupTokenError> = serde_json::from_str(&content).ok();
1900        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1901    }
1902}
1903
1904/// Raises a DRAFT invoice against a customer in the caller's own org.  The invoice is not collectible yet: a draft exists so it can be read and corrected, and issueInvoice is the separate act that turns it into a demand for payment. The subtotal and amount due are computed from the lines, so there is no total to send and none to get wrong.  The billing org is the caller's, taken from the validated principal, so an invoice can only ever be raised on the caller's own books.  A named handler, not a closure, so zipdoc can lift this prose into the registry.
1905pub async fn raise_invoice(configuration: &configuration::Configuration, raise_in: models::RaiseIn) -> Result<models::Invoice, Error<RaiseInvoiceError>> {
1906    // add a prefix to parameters to efficiently prevent name collisions
1907    let p_raise_in = raise_in;
1908
1909    let uri_str = format!("{}/v1/billing/invoices", configuration.base_path);
1910    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1911
1912    if let Some(ref user_agent) = configuration.user_agent {
1913        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1914    }
1915    if let Some(ref token) = configuration.bearer_access_token {
1916        req_builder = req_builder.bearer_auth(token.to_owned());
1917    };
1918    req_builder = req_builder.json(&p_raise_in);
1919
1920    let req = req_builder.build()?;
1921    let resp = configuration.client.execute(req).await?;
1922
1923    let status = resp.status();
1924    let content_type = resp
1925        .headers()
1926        .get("content-type")
1927        .and_then(|v| v.to_str().ok())
1928        .unwrap_or("application/octet-stream");
1929    let content_type = super::ContentType::from(content_type);
1930
1931    if !status.is_client_error() && !status.is_server_error() {
1932        let content = resp.text().await?;
1933        match content_type {
1934            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1935            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Invoice`"))),
1936            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Invoice`")))),
1937        }
1938    } else {
1939        let content = resp.text().await?;
1940        let entity: Option<RaiseInvoiceError> = serde_json::from_str(&content).ok();
1941        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1942    }
1943}
1944
1945/// Puts a canceled subscription back on its plan.  What asks for this is usually a recovered payment method or a support tool rather than a browser, which is most of the argument for it having an address at all. The engine decides whether the move is legal; a row it will not reactivate comes back with its own reason.  A named handler, not a closure, so zipdoc can lift this prose into the registry.
1946pub async fn reactivate_subscription(configuration: &configuration::Configuration, id: &str, subscription_ref: models::SubscriptionRef) -> Result<models::Subscription, Error<ReactivateSubscriptionError>> {
1947    // add a prefix to parameters to efficiently prevent name collisions
1948    let p_id = id;
1949    let p_subscription_ref = subscription_ref;
1950
1951    let uri_str = format!("{}/v1/billing/subscriptions/{id}/reactivate", configuration.base_path, id=crate::apis::urlencode(p_id));
1952    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1953
1954    if let Some(ref user_agent) = configuration.user_agent {
1955        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1956    }
1957    if let Some(ref token) = configuration.bearer_access_token {
1958        req_builder = req_builder.bearer_auth(token.to_owned());
1959    };
1960    req_builder = req_builder.json(&p_subscription_ref);
1961
1962    let req = req_builder.build()?;
1963    let resp = configuration.client.execute(req).await?;
1964
1965    let status = resp.status();
1966    let content_type = resp
1967        .headers()
1968        .get("content-type")
1969        .and_then(|v| v.to_str().ok())
1970        .unwrap_or("application/octet-stream");
1971    let content_type = super::ContentType::from(content_type);
1972
1973    if !status.is_client_error() && !status.is_server_error() {
1974        let content = resp.text().await?;
1975        match content_type {
1976            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1977            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Subscription`"))),
1978            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Subscription`")))),
1979        }
1980    } else {
1981        let content = resp.text().await?;
1982        let entity: Option<ReactivateSubscriptionError> = serde_json::from_str(&content).ok();
1983        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1984    }
1985}
1986
1987/// Voids a draft or issued invoice — the cancel.  A paid invoice cannot be voided: money has moved, and the correction for that is a refund, not an erasure. The state machine refuses it and that refusal is the answer.  A named handler, not a closure, so zipdoc can lift this prose into the registry.
1988pub async fn void_invoice(configuration: &configuration::Configuration, id: &str) -> Result<models::Invoice, Error<VoidInvoiceError>> {
1989    // add a prefix to parameters to efficiently prevent name collisions
1990    let p_id = id;
1991
1992    let uri_str = format!("{}/v1/billing/invoices/{id}/void", configuration.base_path, id=crate::apis::urlencode(p_id));
1993    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1994
1995    if let Some(ref user_agent) = configuration.user_agent {
1996        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1997    }
1998    if let Some(ref token) = configuration.bearer_access_token {
1999        req_builder = req_builder.bearer_auth(token.to_owned());
2000    };
2001
2002    let req = req_builder.build()?;
2003    let resp = configuration.client.execute(req).await?;
2004
2005    let status = resp.status();
2006    let content_type = resp
2007        .headers()
2008        .get("content-type")
2009        .and_then(|v| v.to_str().ok())
2010        .unwrap_or("application/octet-stream");
2011    let content_type = super::ContentType::from(content_type);
2012
2013    if !status.is_client_error() && !status.is_server_error() {
2014        let content = resp.text().await?;
2015        match content_type {
2016            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2017            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Invoice`"))),
2018            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Invoice`")))),
2019        }
2020    } else {
2021        let content = resp.text().await?;
2022        let entity: Option<VoidInvoiceError> = serde_json::from_str(&content).ok();
2023        Err(Error::ResponseError(ResponseContent { status, content, entity }))
2024    }
2025}
2026