1#[derive(Clone)]
36#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
37#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
38pub struct Invoice {
39 pub account_country: Option<String>,
41 pub account_name: Option<String>,
43 pub account_tax_ids: Option<Vec<stripe_types::Expandable<stripe_shared::TaxId>>>,
45 pub amount_due: i64,
50 pub amount_overpaid: i64,
53 pub amount_paid: i64,
55 pub amount_remaining: i64,
57 pub amount_shipping: i64,
59 pub application: Option<stripe_types::Expandable<stripe_shared::Application>>,
61 pub attempt_count: u64,
67 pub attempted: bool,
70 pub auto_advance: Option<bool>,
73 pub automatic_tax: stripe_shared::AutomaticTax,
74 pub automatically_finalizes_at: Option<stripe_types::Timestamp>,
78 pub billing_reason: Option<InvoiceBillingReason>,
89 pub collection_method: stripe_shared::InvoiceCollectionMethod,
93 pub confirmation_secret: Option<stripe_shared::InvoicesResourceConfirmationSecret>,
96 pub created: stripe_types::Timestamp,
98 pub currency: stripe_types::Currency,
101 pub custom_fields: Option<Vec<stripe_shared::InvoiceSettingCustomField>>,
103 pub customer: Option<stripe_types::Expandable<stripe_shared::Customer>>,
105 pub customer_account: Option<String>,
107 pub customer_address: Option<stripe_shared::Address>,
111 pub customer_email: Option<String>,
115 pub customer_name: Option<String>,
119 pub customer_phone: Option<String>,
123 pub customer_shipping: Option<stripe_shared::Shipping>,
127 pub customer_tax_exempt: Option<InvoiceCustomerTaxExempt>,
131 pub customer_tax_ids: Option<Vec<stripe_shared::InvoicesResourceInvoiceTaxId>>,
135 pub default_payment_method: Option<stripe_types::Expandable<stripe_shared::PaymentMethod>>,
139 pub default_source: Option<stripe_types::Expandable<stripe_shared::PaymentSource>>,
143 pub default_tax_rates: Vec<stripe_shared::TaxRate>,
145 pub description: Option<String>,
149 pub discounts: Vec<stripe_types::Expandable<stripe_shared::Discount>>,
153 pub due_date: Option<stripe_types::Timestamp>,
156 pub effective_at: Option<stripe_types::Timestamp>,
160 pub ending_balance: Option<i64>,
164 pub footer: Option<String>,
166 pub from_invoice: Option<stripe_shared::InvoicesResourceFromInvoice>,
169 pub hosted_invoice_url: Option<String>,
172 pub id: Option<stripe_shared::InvoiceId>,
175 pub invoice_pdf: Option<String>,
178 pub issuer: stripe_shared::ConnectAccountReference,
179 pub last_finalization_error: Option<Box<stripe_shared::ApiErrors>>,
182 pub latest_revision: Option<stripe_types::Expandable<stripe_shared::Invoice>>,
184 pub lines: stripe_types::List<stripe_shared::InvoiceLineItem>,
187 pub livemode: bool,
190 pub metadata: Option<std::collections::HashMap<String, String>>,
193 pub next_payment_attempt: Option<stripe_types::Timestamp>,
196 pub number: Option<String>,
199 pub on_behalf_of: Option<stripe_types::Expandable<stripe_shared::Account>>,
203 pub parent: Option<stripe_shared::BillingBillResourceInvoicingParentsInvoiceParent>,
205 pub payment_settings: stripe_shared::InvoicesPaymentSettings,
206 pub payments: Option<stripe_types::List<stripe_shared::InvoicePayment>>,
208 pub period_end: stripe_types::Timestamp,
211 pub period_start: stripe_types::Timestamp,
214 pub post_payment_credit_notes_amount: i64,
216 pub pre_payment_credit_notes_amount: i64,
218 pub receipt_number: Option<String>,
220 pub rendering: Option<stripe_shared::InvoicesResourceInvoiceRendering>,
222 pub shipping_cost: Option<stripe_shared::InvoicesResourceShippingCost>,
224 pub shipping_details: Option<stripe_shared::Shipping>,
227 pub starting_balance: i64,
231 pub statement_descriptor: Option<String>,
233 pub status: Option<stripe_shared::InvoiceStatus>,
236 pub status_transitions: stripe_shared::InvoicesResourceStatusTransitions,
237 pub subscription: Option<stripe_types::Expandable<stripe_shared::Subscription>>,
238 pub subtotal: i64,
241 pub subtotal_excluding_tax: Option<i64>,
244 pub test_clock: Option<stripe_types::Expandable<stripe_shared::TestHelpersTestClock>>,
246 pub threshold_reason: Option<stripe_shared::InvoiceThresholdReason>,
247 pub total: i64,
249 pub total_discount_amounts: Option<Vec<stripe_shared::DiscountsResourceDiscountAmount>>,
251 pub total_excluding_tax: Option<i64>,
253 pub total_pretax_credit_amounts: Option<Vec<stripe_shared::InvoicesResourcePretaxCreditAmount>>,
256 pub total_taxes: Option<Vec<stripe_shared::BillingBillResourceInvoicingTaxesTax>>,
258 pub webhooks_delivered_at: Option<stripe_types::Timestamp>,
262}
263#[cfg(feature = "redact-generated-debug")]
264impl std::fmt::Debug for Invoice {
265 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
266 f.debug_struct("Invoice").finish_non_exhaustive()
267 }
268}
269#[doc(hidden)]
270pub struct InvoiceBuilder {
271 account_country: Option<Option<String>>,
272 account_name: Option<Option<String>>,
273 account_tax_ids: Option<Option<Vec<stripe_types::Expandable<stripe_shared::TaxId>>>>,
274 amount_due: Option<i64>,
275 amount_overpaid: Option<i64>,
276 amount_paid: Option<i64>,
277 amount_remaining: Option<i64>,
278 amount_shipping: Option<i64>,
279 application: Option<Option<stripe_types::Expandable<stripe_shared::Application>>>,
280 attempt_count: Option<u64>,
281 attempted: Option<bool>,
282 auto_advance: Option<Option<bool>>,
283 automatic_tax: Option<stripe_shared::AutomaticTax>,
284 automatically_finalizes_at: Option<Option<stripe_types::Timestamp>>,
285 billing_reason: Option<Option<InvoiceBillingReason>>,
286 collection_method: Option<stripe_shared::InvoiceCollectionMethod>,
287 confirmation_secret: Option<Option<stripe_shared::InvoicesResourceConfirmationSecret>>,
288 created: Option<stripe_types::Timestamp>,
289 currency: Option<stripe_types::Currency>,
290 custom_fields: Option<Option<Vec<stripe_shared::InvoiceSettingCustomField>>>,
291 customer: Option<Option<stripe_types::Expandable<stripe_shared::Customer>>>,
292 customer_account: Option<Option<String>>,
293 customer_address: Option<Option<stripe_shared::Address>>,
294 customer_email: Option<Option<String>>,
295 customer_name: Option<Option<String>>,
296 customer_phone: Option<Option<String>>,
297 customer_shipping: Option<Option<stripe_shared::Shipping>>,
298 customer_tax_exempt: Option<Option<InvoiceCustomerTaxExempt>>,
299 customer_tax_ids: Option<Option<Vec<stripe_shared::InvoicesResourceInvoiceTaxId>>>,
300 default_payment_method: Option<Option<stripe_types::Expandable<stripe_shared::PaymentMethod>>>,
301 default_source: Option<Option<stripe_types::Expandable<stripe_shared::PaymentSource>>>,
302 default_tax_rates: Option<Vec<stripe_shared::TaxRate>>,
303 description: Option<Option<String>>,
304 discounts: Option<Vec<stripe_types::Expandable<stripe_shared::Discount>>>,
305 due_date: Option<Option<stripe_types::Timestamp>>,
306 effective_at: Option<Option<stripe_types::Timestamp>>,
307 ending_balance: Option<Option<i64>>,
308 footer: Option<Option<String>>,
309 from_invoice: Option<Option<stripe_shared::InvoicesResourceFromInvoice>>,
310 hosted_invoice_url: Option<Option<String>>,
311 id: Option<Option<stripe_shared::InvoiceId>>,
312 invoice_pdf: Option<Option<String>>,
313 issuer: Option<stripe_shared::ConnectAccountReference>,
314 last_finalization_error: Option<Option<Box<stripe_shared::ApiErrors>>>,
315 latest_revision: Option<Option<stripe_types::Expandable<stripe_shared::Invoice>>>,
316 lines: Option<stripe_types::List<stripe_shared::InvoiceLineItem>>,
317 livemode: Option<bool>,
318 metadata: Option<Option<std::collections::HashMap<String, String>>>,
319 next_payment_attempt: Option<Option<stripe_types::Timestamp>>,
320 number: Option<Option<String>>,
321 on_behalf_of: Option<Option<stripe_types::Expandable<stripe_shared::Account>>>,
322 parent: Option<Option<stripe_shared::BillingBillResourceInvoicingParentsInvoiceParent>>,
323 payment_settings: Option<stripe_shared::InvoicesPaymentSettings>,
324 payments: Option<Option<stripe_types::List<stripe_shared::InvoicePayment>>>,
325 period_end: Option<stripe_types::Timestamp>,
326 period_start: Option<stripe_types::Timestamp>,
327 post_payment_credit_notes_amount: Option<i64>,
328 pre_payment_credit_notes_amount: Option<i64>,
329 receipt_number: Option<Option<String>>,
330 rendering: Option<Option<stripe_shared::InvoicesResourceInvoiceRendering>>,
331 shipping_cost: Option<Option<stripe_shared::InvoicesResourceShippingCost>>,
332 shipping_details: Option<Option<stripe_shared::Shipping>>,
333 starting_balance: Option<i64>,
334 statement_descriptor: Option<Option<String>>,
335 status: Option<Option<stripe_shared::InvoiceStatus>>,
336 status_transitions: Option<stripe_shared::InvoicesResourceStatusTransitions>,
337 subscription: Option<Option<stripe_types::Expandable<stripe_shared::Subscription>>>,
338 subtotal: Option<i64>,
339 subtotal_excluding_tax: Option<Option<i64>>,
340 test_clock: Option<Option<stripe_types::Expandable<stripe_shared::TestHelpersTestClock>>>,
341 threshold_reason: Option<Option<stripe_shared::InvoiceThresholdReason>>,
342 total: Option<i64>,
343 total_discount_amounts: Option<Option<Vec<stripe_shared::DiscountsResourceDiscountAmount>>>,
344 total_excluding_tax: Option<Option<i64>>,
345 total_pretax_credit_amounts:
346 Option<Option<Vec<stripe_shared::InvoicesResourcePretaxCreditAmount>>>,
347 total_taxes: Option<Option<Vec<stripe_shared::BillingBillResourceInvoicingTaxesTax>>>,
348 webhooks_delivered_at: Option<Option<stripe_types::Timestamp>>,
349}
350
351#[allow(
352 unused_variables,
353 irrefutable_let_patterns,
354 clippy::let_unit_value,
355 clippy::match_single_binding,
356 clippy::single_match
357)]
358const _: () = {
359 use miniserde::de::{Map, Visitor};
360 use miniserde::json::Value;
361 use miniserde::{Deserialize, Result, make_place};
362 use stripe_types::miniserde_helpers::FromValueOpt;
363 use stripe_types::{MapBuilder, ObjectDeser};
364
365 make_place!(Place);
366
367 impl Deserialize for Invoice {
368 fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
369 Place::new(out)
370 }
371 }
372
373 struct Builder<'a> {
374 out: &'a mut Option<Invoice>,
375 builder: InvoiceBuilder,
376 }
377
378 impl Visitor for Place<Invoice> {
379 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
380 Ok(Box::new(Builder { out: &mut self.out, builder: InvoiceBuilder::deser_default() }))
381 }
382 }
383
384 impl MapBuilder for InvoiceBuilder {
385 type Out = Invoice;
386 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
387 Ok(match k {
388 "account_country" => Deserialize::begin(&mut self.account_country),
389 "account_name" => Deserialize::begin(&mut self.account_name),
390 "account_tax_ids" => Deserialize::begin(&mut self.account_tax_ids),
391 "amount_due" => Deserialize::begin(&mut self.amount_due),
392 "amount_overpaid" => Deserialize::begin(&mut self.amount_overpaid),
393 "amount_paid" => Deserialize::begin(&mut self.amount_paid),
394 "amount_remaining" => Deserialize::begin(&mut self.amount_remaining),
395 "amount_shipping" => Deserialize::begin(&mut self.amount_shipping),
396 "application" => Deserialize::begin(&mut self.application),
397 "attempt_count" => Deserialize::begin(&mut self.attempt_count),
398 "attempted" => Deserialize::begin(&mut self.attempted),
399 "auto_advance" => Deserialize::begin(&mut self.auto_advance),
400 "automatic_tax" => Deserialize::begin(&mut self.automatic_tax),
401 "automatically_finalizes_at" => {
402 Deserialize::begin(&mut self.automatically_finalizes_at)
403 }
404 "billing_reason" => Deserialize::begin(&mut self.billing_reason),
405 "collection_method" => Deserialize::begin(&mut self.collection_method),
406 "confirmation_secret" => Deserialize::begin(&mut self.confirmation_secret),
407 "created" => Deserialize::begin(&mut self.created),
408 "currency" => Deserialize::begin(&mut self.currency),
409 "custom_fields" => Deserialize::begin(&mut self.custom_fields),
410 "customer" => Deserialize::begin(&mut self.customer),
411 "customer_account" => Deserialize::begin(&mut self.customer_account),
412 "customer_address" => Deserialize::begin(&mut self.customer_address),
413 "customer_email" => Deserialize::begin(&mut self.customer_email),
414 "customer_name" => Deserialize::begin(&mut self.customer_name),
415 "customer_phone" => Deserialize::begin(&mut self.customer_phone),
416 "customer_shipping" => Deserialize::begin(&mut self.customer_shipping),
417 "customer_tax_exempt" => Deserialize::begin(&mut self.customer_tax_exempt),
418 "customer_tax_ids" => Deserialize::begin(&mut self.customer_tax_ids),
419 "default_payment_method" => Deserialize::begin(&mut self.default_payment_method),
420 "default_source" => Deserialize::begin(&mut self.default_source),
421 "default_tax_rates" => Deserialize::begin(&mut self.default_tax_rates),
422 "description" => Deserialize::begin(&mut self.description),
423 "discounts" => Deserialize::begin(&mut self.discounts),
424 "due_date" => Deserialize::begin(&mut self.due_date),
425 "effective_at" => Deserialize::begin(&mut self.effective_at),
426 "ending_balance" => Deserialize::begin(&mut self.ending_balance),
427 "footer" => Deserialize::begin(&mut self.footer),
428 "from_invoice" => Deserialize::begin(&mut self.from_invoice),
429 "hosted_invoice_url" => Deserialize::begin(&mut self.hosted_invoice_url),
430 "id" => Deserialize::begin(&mut self.id),
431 "invoice_pdf" => Deserialize::begin(&mut self.invoice_pdf),
432 "issuer" => Deserialize::begin(&mut self.issuer),
433 "last_finalization_error" => Deserialize::begin(&mut self.last_finalization_error),
434 "latest_revision" => Deserialize::begin(&mut self.latest_revision),
435 "lines" => Deserialize::begin(&mut self.lines),
436 "livemode" => Deserialize::begin(&mut self.livemode),
437 "metadata" => Deserialize::begin(&mut self.metadata),
438 "next_payment_attempt" => Deserialize::begin(&mut self.next_payment_attempt),
439 "number" => Deserialize::begin(&mut self.number),
440 "on_behalf_of" => Deserialize::begin(&mut self.on_behalf_of),
441 "parent" => Deserialize::begin(&mut self.parent),
442 "payment_settings" => Deserialize::begin(&mut self.payment_settings),
443 "payments" => Deserialize::begin(&mut self.payments),
444 "period_end" => Deserialize::begin(&mut self.period_end),
445 "period_start" => Deserialize::begin(&mut self.period_start),
446 "post_payment_credit_notes_amount" => {
447 Deserialize::begin(&mut self.post_payment_credit_notes_amount)
448 }
449 "pre_payment_credit_notes_amount" => {
450 Deserialize::begin(&mut self.pre_payment_credit_notes_amount)
451 }
452 "receipt_number" => Deserialize::begin(&mut self.receipt_number),
453 "rendering" => Deserialize::begin(&mut self.rendering),
454 "shipping_cost" => Deserialize::begin(&mut self.shipping_cost),
455 "shipping_details" => Deserialize::begin(&mut self.shipping_details),
456 "starting_balance" => Deserialize::begin(&mut self.starting_balance),
457 "statement_descriptor" => Deserialize::begin(&mut self.statement_descriptor),
458 "status" => Deserialize::begin(&mut self.status),
459 "status_transitions" => Deserialize::begin(&mut self.status_transitions),
460 "subscription" => Deserialize::begin(&mut self.subscription),
461 "subtotal" => Deserialize::begin(&mut self.subtotal),
462 "subtotal_excluding_tax" => Deserialize::begin(&mut self.subtotal_excluding_tax),
463 "test_clock" => Deserialize::begin(&mut self.test_clock),
464 "threshold_reason" => Deserialize::begin(&mut self.threshold_reason),
465 "total" => Deserialize::begin(&mut self.total),
466 "total_discount_amounts" => Deserialize::begin(&mut self.total_discount_amounts),
467 "total_excluding_tax" => Deserialize::begin(&mut self.total_excluding_tax),
468 "total_pretax_credit_amounts" => {
469 Deserialize::begin(&mut self.total_pretax_credit_amounts)
470 }
471 "total_taxes" => Deserialize::begin(&mut self.total_taxes),
472 "webhooks_delivered_at" => Deserialize::begin(&mut self.webhooks_delivered_at),
473 _ => <dyn Visitor>::ignore(),
474 })
475 }
476
477 fn deser_default() -> Self {
478 Self {
479 account_country: Some(None),
480 account_name: Some(None),
481 account_tax_ids: Some(None),
482 amount_due: None,
483 amount_overpaid: None,
484 amount_paid: None,
485 amount_remaining: None,
486 amount_shipping: None,
487 application: Some(None),
488 attempt_count: None,
489 attempted: None,
490 auto_advance: Some(None),
491 automatic_tax: None,
492 automatically_finalizes_at: Some(None),
493 billing_reason: Some(None),
494 collection_method: None,
495 confirmation_secret: Some(None),
496 created: None,
497 currency: None,
498 custom_fields: Some(None),
499 customer: Some(None),
500 customer_account: Some(None),
501 customer_address: Some(None),
502 customer_email: Some(None),
503 customer_name: Some(None),
504 customer_phone: Some(None),
505 customer_shipping: Some(None),
506 customer_tax_exempt: Some(None),
507 customer_tax_ids: Some(None),
508 default_payment_method: Some(None),
509 default_source: Some(None),
510 default_tax_rates: None,
511 description: Some(None),
512 discounts: None,
513 due_date: Some(None),
514 effective_at: Some(None),
515 ending_balance: Some(None),
516 footer: Some(None),
517 from_invoice: Some(None),
518 hosted_invoice_url: Some(None),
519 id: Some(None),
520 invoice_pdf: Some(None),
521 issuer: None,
522 last_finalization_error: Some(None),
523 latest_revision: Some(None),
524 lines: None,
525 livemode: None,
526 metadata: Some(None),
527 next_payment_attempt: Some(None),
528 number: Some(None),
529 on_behalf_of: Some(None),
530 parent: Some(None),
531 payment_settings: None,
532 payments: Some(None),
533 period_end: None,
534 period_start: None,
535 post_payment_credit_notes_amount: None,
536 pre_payment_credit_notes_amount: None,
537 receipt_number: Some(None),
538 rendering: Some(None),
539 shipping_cost: Some(None),
540 shipping_details: Some(None),
541 starting_balance: None,
542 statement_descriptor: Some(None),
543 status: Some(None),
544 status_transitions: None,
545 subscription: Some(None),
546 subtotal: None,
547 subtotal_excluding_tax: Some(None),
548 test_clock: Some(None),
549 threshold_reason: Some(None),
550 total: None,
551 total_discount_amounts: Some(None),
552 total_excluding_tax: Some(None),
553 total_pretax_credit_amounts: Some(None),
554 total_taxes: Some(None),
555 webhooks_delivered_at: Some(None),
556 }
557 }
558
559 fn take_out(&mut self) -> Option<Self::Out> {
560 let (
561 Some(account_country),
562 Some(account_name),
563 Some(account_tax_ids),
564 Some(amount_due),
565 Some(amount_overpaid),
566 Some(amount_paid),
567 Some(amount_remaining),
568 Some(amount_shipping),
569 Some(application),
570 Some(attempt_count),
571 Some(attempted),
572 Some(auto_advance),
573 Some(automatic_tax),
574 Some(automatically_finalizes_at),
575 Some(billing_reason),
576 Some(collection_method),
577 Some(confirmation_secret),
578 Some(created),
579 Some(currency),
580 Some(custom_fields),
581 Some(customer),
582 Some(customer_account),
583 Some(customer_address),
584 Some(customer_email),
585 Some(customer_name),
586 Some(customer_phone),
587 Some(customer_shipping),
588 Some(customer_tax_exempt),
589 Some(customer_tax_ids),
590 Some(default_payment_method),
591 Some(default_source),
592 Some(default_tax_rates),
593 Some(description),
594 Some(discounts),
595 Some(due_date),
596 Some(effective_at),
597 Some(ending_balance),
598 Some(footer),
599 Some(from_invoice),
600 Some(hosted_invoice_url),
601 Some(id),
602 Some(invoice_pdf),
603 Some(issuer),
604 Some(last_finalization_error),
605 Some(latest_revision),
606 Some(lines),
607 Some(livemode),
608 Some(metadata),
609 Some(next_payment_attempt),
610 Some(number),
611 Some(on_behalf_of),
612 Some(parent),
613 Some(payment_settings),
614 Some(payments),
615 Some(period_end),
616 Some(period_start),
617 Some(post_payment_credit_notes_amount),
618 Some(pre_payment_credit_notes_amount),
619 Some(receipt_number),
620 Some(rendering),
621 Some(shipping_cost),
622 Some(shipping_details),
623 Some(starting_balance),
624 Some(statement_descriptor),
625 Some(status),
626 Some(status_transitions),
627 Some(subscription),
628 Some(subtotal),
629 Some(subtotal_excluding_tax),
630 Some(test_clock),
631 Some(threshold_reason),
632 Some(total),
633 Some(total_discount_amounts),
634 Some(total_excluding_tax),
635 Some(total_pretax_credit_amounts),
636 Some(total_taxes),
637 Some(webhooks_delivered_at),
638 ) = (
639 self.account_country.take(),
640 self.account_name.take(),
641 self.account_tax_ids.take(),
642 self.amount_due,
643 self.amount_overpaid,
644 self.amount_paid,
645 self.amount_remaining,
646 self.amount_shipping,
647 self.application.take(),
648 self.attempt_count,
649 self.attempted,
650 self.auto_advance,
651 self.automatic_tax.take(),
652 self.automatically_finalizes_at,
653 self.billing_reason.take(),
654 self.collection_method.take(),
655 self.confirmation_secret.take(),
656 self.created,
657 self.currency.take(),
658 self.custom_fields.take(),
659 self.customer.take(),
660 self.customer_account.take(),
661 self.customer_address.take(),
662 self.customer_email.take(),
663 self.customer_name.take(),
664 self.customer_phone.take(),
665 self.customer_shipping.take(),
666 self.customer_tax_exempt.take(),
667 self.customer_tax_ids.take(),
668 self.default_payment_method.take(),
669 self.default_source.take(),
670 self.default_tax_rates.take(),
671 self.description.take(),
672 self.discounts.take(),
673 self.due_date,
674 self.effective_at,
675 self.ending_balance,
676 self.footer.take(),
677 self.from_invoice.take(),
678 self.hosted_invoice_url.take(),
679 self.id.take(),
680 self.invoice_pdf.take(),
681 self.issuer.take(),
682 self.last_finalization_error.take(),
683 self.latest_revision.take(),
684 self.lines.take(),
685 self.livemode,
686 self.metadata.take(),
687 self.next_payment_attempt,
688 self.number.take(),
689 self.on_behalf_of.take(),
690 self.parent.take(),
691 self.payment_settings.take(),
692 self.payments.take(),
693 self.period_end,
694 self.period_start,
695 self.post_payment_credit_notes_amount,
696 self.pre_payment_credit_notes_amount,
697 self.receipt_number.take(),
698 self.rendering.take(),
699 self.shipping_cost.take(),
700 self.shipping_details.take(),
701 self.starting_balance,
702 self.statement_descriptor.take(),
703 self.status.take(),
704 self.status_transitions,
705 self.subscription.take(),
706 self.subtotal,
707 self.subtotal_excluding_tax,
708 self.test_clock.take(),
709 self.threshold_reason.take(),
710 self.total,
711 self.total_discount_amounts.take(),
712 self.total_excluding_tax,
713 self.total_pretax_credit_amounts.take(),
714 self.total_taxes.take(),
715 self.webhooks_delivered_at,
716 )
717 else {
718 return None;
719 };
720 Some(Self::Out {
721 account_country,
722 account_name,
723 account_tax_ids,
724 amount_due,
725 amount_overpaid,
726 amount_paid,
727 amount_remaining,
728 amount_shipping,
729 application,
730 attempt_count,
731 attempted,
732 auto_advance,
733 automatic_tax,
734 automatically_finalizes_at,
735 billing_reason,
736 collection_method,
737 confirmation_secret,
738 created,
739 currency,
740 custom_fields,
741 customer,
742 customer_account,
743 customer_address,
744 customer_email,
745 customer_name,
746 customer_phone,
747 customer_shipping,
748 customer_tax_exempt,
749 customer_tax_ids,
750 default_payment_method,
751 default_source,
752 default_tax_rates,
753 description,
754 discounts,
755 due_date,
756 effective_at,
757 ending_balance,
758 footer,
759 from_invoice,
760 hosted_invoice_url,
761 id,
762 invoice_pdf,
763 issuer,
764 last_finalization_error,
765 latest_revision,
766 lines,
767 livemode,
768 metadata,
769 next_payment_attempt,
770 number,
771 on_behalf_of,
772 parent,
773 payment_settings,
774 payments,
775 period_end,
776 period_start,
777 post_payment_credit_notes_amount,
778 pre_payment_credit_notes_amount,
779 receipt_number,
780 rendering,
781 shipping_cost,
782 shipping_details,
783 starting_balance,
784 statement_descriptor,
785 status,
786 status_transitions,
787 subscription,
788 subtotal,
789 subtotal_excluding_tax,
790 test_clock,
791 threshold_reason,
792 total,
793 total_discount_amounts,
794 total_excluding_tax,
795 total_pretax_credit_amounts,
796 total_taxes,
797 webhooks_delivered_at,
798 })
799 }
800 }
801
802 impl Map for Builder<'_> {
803 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
804 self.builder.key(k)
805 }
806
807 fn finish(&mut self) -> Result<()> {
808 *self.out = self.builder.take_out();
809 Ok(())
810 }
811 }
812
813 impl ObjectDeser for Invoice {
814 type Builder = InvoiceBuilder;
815 }
816
817 impl FromValueOpt for Invoice {
818 fn from_value(v: Value) -> Option<Self> {
819 let Value::Object(obj) = v else {
820 return None;
821 };
822 let mut b = InvoiceBuilder::deser_default();
823 for (k, v) in obj {
824 match k.as_str() {
825 "account_country" => b.account_country = FromValueOpt::from_value(v),
826 "account_name" => b.account_name = FromValueOpt::from_value(v),
827 "account_tax_ids" => b.account_tax_ids = FromValueOpt::from_value(v),
828 "amount_due" => b.amount_due = FromValueOpt::from_value(v),
829 "amount_overpaid" => b.amount_overpaid = FromValueOpt::from_value(v),
830 "amount_paid" => b.amount_paid = FromValueOpt::from_value(v),
831 "amount_remaining" => b.amount_remaining = FromValueOpt::from_value(v),
832 "amount_shipping" => b.amount_shipping = FromValueOpt::from_value(v),
833 "application" => b.application = FromValueOpt::from_value(v),
834 "attempt_count" => b.attempt_count = FromValueOpt::from_value(v),
835 "attempted" => b.attempted = FromValueOpt::from_value(v),
836 "auto_advance" => b.auto_advance = FromValueOpt::from_value(v),
837 "automatic_tax" => b.automatic_tax = FromValueOpt::from_value(v),
838 "automatically_finalizes_at" => {
839 b.automatically_finalizes_at = FromValueOpt::from_value(v)
840 }
841 "billing_reason" => b.billing_reason = FromValueOpt::from_value(v),
842 "collection_method" => b.collection_method = FromValueOpt::from_value(v),
843 "confirmation_secret" => b.confirmation_secret = FromValueOpt::from_value(v),
844 "created" => b.created = FromValueOpt::from_value(v),
845 "currency" => b.currency = FromValueOpt::from_value(v),
846 "custom_fields" => b.custom_fields = FromValueOpt::from_value(v),
847 "customer" => b.customer = FromValueOpt::from_value(v),
848 "customer_account" => b.customer_account = FromValueOpt::from_value(v),
849 "customer_address" => b.customer_address = FromValueOpt::from_value(v),
850 "customer_email" => b.customer_email = FromValueOpt::from_value(v),
851 "customer_name" => b.customer_name = FromValueOpt::from_value(v),
852 "customer_phone" => b.customer_phone = FromValueOpt::from_value(v),
853 "customer_shipping" => b.customer_shipping = FromValueOpt::from_value(v),
854 "customer_tax_exempt" => b.customer_tax_exempt = FromValueOpt::from_value(v),
855 "customer_tax_ids" => b.customer_tax_ids = FromValueOpt::from_value(v),
856 "default_payment_method" => {
857 b.default_payment_method = FromValueOpt::from_value(v)
858 }
859 "default_source" => b.default_source = FromValueOpt::from_value(v),
860 "default_tax_rates" => b.default_tax_rates = FromValueOpt::from_value(v),
861 "description" => b.description = FromValueOpt::from_value(v),
862 "discounts" => b.discounts = FromValueOpt::from_value(v),
863 "due_date" => b.due_date = FromValueOpt::from_value(v),
864 "effective_at" => b.effective_at = FromValueOpt::from_value(v),
865 "ending_balance" => b.ending_balance = FromValueOpt::from_value(v),
866 "footer" => b.footer = FromValueOpt::from_value(v),
867 "from_invoice" => b.from_invoice = FromValueOpt::from_value(v),
868 "hosted_invoice_url" => b.hosted_invoice_url = FromValueOpt::from_value(v),
869 "id" => b.id = FromValueOpt::from_value(v),
870 "invoice_pdf" => b.invoice_pdf = FromValueOpt::from_value(v),
871 "issuer" => b.issuer = FromValueOpt::from_value(v),
872 "last_finalization_error" => {
873 b.last_finalization_error = FromValueOpt::from_value(v)
874 }
875 "latest_revision" => b.latest_revision = FromValueOpt::from_value(v),
876 "lines" => b.lines = FromValueOpt::from_value(v),
877 "livemode" => b.livemode = FromValueOpt::from_value(v),
878 "metadata" => b.metadata = FromValueOpt::from_value(v),
879 "next_payment_attempt" => b.next_payment_attempt = FromValueOpt::from_value(v),
880 "number" => b.number = FromValueOpt::from_value(v),
881 "on_behalf_of" => b.on_behalf_of = FromValueOpt::from_value(v),
882 "parent" => b.parent = FromValueOpt::from_value(v),
883 "payment_settings" => b.payment_settings = FromValueOpt::from_value(v),
884 "payments" => b.payments = FromValueOpt::from_value(v),
885 "period_end" => b.period_end = FromValueOpt::from_value(v),
886 "period_start" => b.period_start = FromValueOpt::from_value(v),
887 "post_payment_credit_notes_amount" => {
888 b.post_payment_credit_notes_amount = FromValueOpt::from_value(v)
889 }
890 "pre_payment_credit_notes_amount" => {
891 b.pre_payment_credit_notes_amount = FromValueOpt::from_value(v)
892 }
893 "receipt_number" => b.receipt_number = FromValueOpt::from_value(v),
894 "rendering" => b.rendering = FromValueOpt::from_value(v),
895 "shipping_cost" => b.shipping_cost = FromValueOpt::from_value(v),
896 "shipping_details" => b.shipping_details = FromValueOpt::from_value(v),
897 "starting_balance" => b.starting_balance = FromValueOpt::from_value(v),
898 "statement_descriptor" => b.statement_descriptor = FromValueOpt::from_value(v),
899 "status" => b.status = FromValueOpt::from_value(v),
900 "status_transitions" => b.status_transitions = FromValueOpt::from_value(v),
901 "subscription" => b.subscription = FromValueOpt::from_value(v),
902 "subtotal" => b.subtotal = FromValueOpt::from_value(v),
903 "subtotal_excluding_tax" => {
904 b.subtotal_excluding_tax = FromValueOpt::from_value(v)
905 }
906 "test_clock" => b.test_clock = FromValueOpt::from_value(v),
907 "threshold_reason" => b.threshold_reason = FromValueOpt::from_value(v),
908 "total" => b.total = FromValueOpt::from_value(v),
909 "total_discount_amounts" => {
910 b.total_discount_amounts = FromValueOpt::from_value(v)
911 }
912 "total_excluding_tax" => b.total_excluding_tax = FromValueOpt::from_value(v),
913 "total_pretax_credit_amounts" => {
914 b.total_pretax_credit_amounts = FromValueOpt::from_value(v)
915 }
916 "total_taxes" => b.total_taxes = FromValueOpt::from_value(v),
917 "webhooks_delivered_at" => {
918 b.webhooks_delivered_at = FromValueOpt::from_value(v)
919 }
920 _ => {}
921 }
922 }
923 b.take_out()
924 }
925 }
926};
927#[cfg(feature = "serialize")]
928impl serde::Serialize for Invoice {
929 fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
930 use serde::ser::SerializeStruct;
931 let mut s = s.serialize_struct("Invoice", 78)?;
932 s.serialize_field("account_country", &self.account_country)?;
933 s.serialize_field("account_name", &self.account_name)?;
934 s.serialize_field("account_tax_ids", &self.account_tax_ids)?;
935 s.serialize_field("amount_due", &self.amount_due)?;
936 s.serialize_field("amount_overpaid", &self.amount_overpaid)?;
937 s.serialize_field("amount_paid", &self.amount_paid)?;
938 s.serialize_field("amount_remaining", &self.amount_remaining)?;
939 s.serialize_field("amount_shipping", &self.amount_shipping)?;
940 s.serialize_field("application", &self.application)?;
941 s.serialize_field("attempt_count", &self.attempt_count)?;
942 s.serialize_field("attempted", &self.attempted)?;
943 s.serialize_field("auto_advance", &self.auto_advance)?;
944 s.serialize_field("automatic_tax", &self.automatic_tax)?;
945 s.serialize_field("automatically_finalizes_at", &self.automatically_finalizes_at)?;
946 s.serialize_field("billing_reason", &self.billing_reason)?;
947 s.serialize_field("collection_method", &self.collection_method)?;
948 s.serialize_field("confirmation_secret", &self.confirmation_secret)?;
949 s.serialize_field("created", &self.created)?;
950 s.serialize_field("currency", &self.currency)?;
951 s.serialize_field("custom_fields", &self.custom_fields)?;
952 s.serialize_field("customer", &self.customer)?;
953 s.serialize_field("customer_account", &self.customer_account)?;
954 s.serialize_field("customer_address", &self.customer_address)?;
955 s.serialize_field("customer_email", &self.customer_email)?;
956 s.serialize_field("customer_name", &self.customer_name)?;
957 s.serialize_field("customer_phone", &self.customer_phone)?;
958 s.serialize_field("customer_shipping", &self.customer_shipping)?;
959 s.serialize_field("customer_tax_exempt", &self.customer_tax_exempt)?;
960 s.serialize_field("customer_tax_ids", &self.customer_tax_ids)?;
961 s.serialize_field("default_payment_method", &self.default_payment_method)?;
962 s.serialize_field("default_source", &self.default_source)?;
963 s.serialize_field("default_tax_rates", &self.default_tax_rates)?;
964 s.serialize_field("description", &self.description)?;
965 s.serialize_field("discounts", &self.discounts)?;
966 s.serialize_field("due_date", &self.due_date)?;
967 s.serialize_field("effective_at", &self.effective_at)?;
968 s.serialize_field("ending_balance", &self.ending_balance)?;
969 s.serialize_field("footer", &self.footer)?;
970 s.serialize_field("from_invoice", &self.from_invoice)?;
971 s.serialize_field("hosted_invoice_url", &self.hosted_invoice_url)?;
972 s.serialize_field("id", &self.id)?;
973 s.serialize_field("invoice_pdf", &self.invoice_pdf)?;
974 s.serialize_field("issuer", &self.issuer)?;
975 s.serialize_field("last_finalization_error", &self.last_finalization_error)?;
976 s.serialize_field("latest_revision", &self.latest_revision)?;
977 s.serialize_field("lines", &self.lines)?;
978 s.serialize_field("livemode", &self.livemode)?;
979 s.serialize_field("metadata", &self.metadata)?;
980 s.serialize_field("next_payment_attempt", &self.next_payment_attempt)?;
981 s.serialize_field("number", &self.number)?;
982 s.serialize_field("on_behalf_of", &self.on_behalf_of)?;
983 s.serialize_field("parent", &self.parent)?;
984 s.serialize_field("payment_settings", &self.payment_settings)?;
985 s.serialize_field("payments", &self.payments)?;
986 s.serialize_field("period_end", &self.period_end)?;
987 s.serialize_field("period_start", &self.period_start)?;
988 s.serialize_field(
989 "post_payment_credit_notes_amount",
990 &self.post_payment_credit_notes_amount,
991 )?;
992 s.serialize_field(
993 "pre_payment_credit_notes_amount",
994 &self.pre_payment_credit_notes_amount,
995 )?;
996 s.serialize_field("receipt_number", &self.receipt_number)?;
997 s.serialize_field("rendering", &self.rendering)?;
998 s.serialize_field("shipping_cost", &self.shipping_cost)?;
999 s.serialize_field("shipping_details", &self.shipping_details)?;
1000 s.serialize_field("starting_balance", &self.starting_balance)?;
1001 s.serialize_field("statement_descriptor", &self.statement_descriptor)?;
1002 s.serialize_field("status", &self.status)?;
1003 s.serialize_field("status_transitions", &self.status_transitions)?;
1004 s.serialize_field("subscription", &self.subscription)?;
1005 s.serialize_field("subtotal", &self.subtotal)?;
1006 s.serialize_field("subtotal_excluding_tax", &self.subtotal_excluding_tax)?;
1007 s.serialize_field("test_clock", &self.test_clock)?;
1008 s.serialize_field("threshold_reason", &self.threshold_reason)?;
1009 s.serialize_field("total", &self.total)?;
1010 s.serialize_field("total_discount_amounts", &self.total_discount_amounts)?;
1011 s.serialize_field("total_excluding_tax", &self.total_excluding_tax)?;
1012 s.serialize_field("total_pretax_credit_amounts", &self.total_pretax_credit_amounts)?;
1013 s.serialize_field("total_taxes", &self.total_taxes)?;
1014 s.serialize_field("webhooks_delivered_at", &self.webhooks_delivered_at)?;
1015
1016 s.serialize_field("object", "invoice")?;
1017 s.end()
1018 }
1019}
1020#[derive(Clone, Eq, PartialEq)]
1031#[non_exhaustive]
1032pub enum InvoiceBillingReason {
1033 AutomaticPendingInvoiceItemInvoice,
1034 Manual,
1035 QuoteAccept,
1036 Subscription,
1037 SubscriptionCreate,
1038 SubscriptionCycle,
1039 SubscriptionThreshold,
1040 SubscriptionUpdate,
1041 Upcoming,
1042 Unknown(String),
1044}
1045impl InvoiceBillingReason {
1046 pub fn as_str(&self) -> &str {
1047 use InvoiceBillingReason::*;
1048 match self {
1049 AutomaticPendingInvoiceItemInvoice => "automatic_pending_invoice_item_invoice",
1050 Manual => "manual",
1051 QuoteAccept => "quote_accept",
1052 Subscription => "subscription",
1053 SubscriptionCreate => "subscription_create",
1054 SubscriptionCycle => "subscription_cycle",
1055 SubscriptionThreshold => "subscription_threshold",
1056 SubscriptionUpdate => "subscription_update",
1057 Upcoming => "upcoming",
1058 Unknown(v) => v,
1059 }
1060 }
1061}
1062
1063impl std::str::FromStr for InvoiceBillingReason {
1064 type Err = std::convert::Infallible;
1065 fn from_str(s: &str) -> Result<Self, Self::Err> {
1066 use InvoiceBillingReason::*;
1067 match s {
1068 "automatic_pending_invoice_item_invoice" => Ok(AutomaticPendingInvoiceItemInvoice),
1069 "manual" => Ok(Manual),
1070 "quote_accept" => Ok(QuoteAccept),
1071 "subscription" => Ok(Subscription),
1072 "subscription_create" => Ok(SubscriptionCreate),
1073 "subscription_cycle" => Ok(SubscriptionCycle),
1074 "subscription_threshold" => Ok(SubscriptionThreshold),
1075 "subscription_update" => Ok(SubscriptionUpdate),
1076 "upcoming" => Ok(Upcoming),
1077 v => {
1078 tracing::warn!("Unknown value '{}' for enum '{}'", v, "InvoiceBillingReason");
1079 Ok(Unknown(v.to_owned()))
1080 }
1081 }
1082 }
1083}
1084impl std::fmt::Display for InvoiceBillingReason {
1085 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1086 f.write_str(self.as_str())
1087 }
1088}
1089
1090#[cfg(not(feature = "redact-generated-debug"))]
1091impl std::fmt::Debug for InvoiceBillingReason {
1092 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1093 f.write_str(self.as_str())
1094 }
1095}
1096#[cfg(feature = "redact-generated-debug")]
1097impl std::fmt::Debug for InvoiceBillingReason {
1098 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1099 f.debug_struct(stringify!(InvoiceBillingReason)).finish_non_exhaustive()
1100 }
1101}
1102#[cfg(feature = "serialize")]
1103impl serde::Serialize for InvoiceBillingReason {
1104 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1105 where
1106 S: serde::Serializer,
1107 {
1108 serializer.serialize_str(self.as_str())
1109 }
1110}
1111impl miniserde::Deserialize for InvoiceBillingReason {
1112 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
1113 crate::Place::new(out)
1114 }
1115}
1116
1117impl miniserde::de::Visitor for crate::Place<InvoiceBillingReason> {
1118 fn string(&mut self, s: &str) -> miniserde::Result<()> {
1119 use std::str::FromStr;
1120 self.out = Some(InvoiceBillingReason::from_str(s).expect("infallible"));
1121 Ok(())
1122 }
1123}
1124
1125stripe_types::impl_from_val_with_from_str!(InvoiceBillingReason);
1126#[cfg(feature = "deserialize")]
1127impl<'de> serde::Deserialize<'de> for InvoiceBillingReason {
1128 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1129 use std::str::FromStr;
1130 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
1131 Ok(Self::from_str(&s).expect("infallible"))
1132 }
1133}
1134#[derive(Clone, Eq, PartialEq)]
1138#[non_exhaustive]
1139pub enum InvoiceCustomerTaxExempt {
1140 Exempt,
1141 None,
1142 Reverse,
1143 Unknown(String),
1145}
1146impl InvoiceCustomerTaxExempt {
1147 pub fn as_str(&self) -> &str {
1148 use InvoiceCustomerTaxExempt::*;
1149 match self {
1150 Exempt => "exempt",
1151 None => "none",
1152 Reverse => "reverse",
1153 Unknown(v) => v,
1154 }
1155 }
1156}
1157
1158impl std::str::FromStr for InvoiceCustomerTaxExempt {
1159 type Err = std::convert::Infallible;
1160 fn from_str(s: &str) -> Result<Self, Self::Err> {
1161 use InvoiceCustomerTaxExempt::*;
1162 match s {
1163 "exempt" => Ok(Exempt),
1164 "none" => Ok(None),
1165 "reverse" => Ok(Reverse),
1166 v => {
1167 tracing::warn!("Unknown value '{}' for enum '{}'", v, "InvoiceCustomerTaxExempt");
1168 Ok(Unknown(v.to_owned()))
1169 }
1170 }
1171 }
1172}
1173impl std::fmt::Display for InvoiceCustomerTaxExempt {
1174 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1175 f.write_str(self.as_str())
1176 }
1177}
1178
1179#[cfg(not(feature = "redact-generated-debug"))]
1180impl std::fmt::Debug for InvoiceCustomerTaxExempt {
1181 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1182 f.write_str(self.as_str())
1183 }
1184}
1185#[cfg(feature = "redact-generated-debug")]
1186impl std::fmt::Debug for InvoiceCustomerTaxExempt {
1187 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1188 f.debug_struct(stringify!(InvoiceCustomerTaxExempt)).finish_non_exhaustive()
1189 }
1190}
1191#[cfg(feature = "serialize")]
1192impl serde::Serialize for InvoiceCustomerTaxExempt {
1193 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1194 where
1195 S: serde::Serializer,
1196 {
1197 serializer.serialize_str(self.as_str())
1198 }
1199}
1200impl miniserde::Deserialize for InvoiceCustomerTaxExempt {
1201 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
1202 crate::Place::new(out)
1203 }
1204}
1205
1206impl miniserde::de::Visitor for crate::Place<InvoiceCustomerTaxExempt> {
1207 fn string(&mut self, s: &str) -> miniserde::Result<()> {
1208 use std::str::FromStr;
1209 self.out = Some(InvoiceCustomerTaxExempt::from_str(s).expect("infallible"));
1210 Ok(())
1211 }
1212}
1213
1214stripe_types::impl_from_val_with_from_str!(InvoiceCustomerTaxExempt);
1215#[cfg(feature = "deserialize")]
1216impl<'de> serde::Deserialize<'de> for InvoiceCustomerTaxExempt {
1217 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1218 use std::str::FromStr;
1219 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
1220 Ok(Self::from_str(&s).expect("infallible"))
1221 }
1222}
1223impl stripe_types::Object for Invoice {
1224 type Id = Option<stripe_shared::InvoiceId>;
1225 fn id(&self) -> &Self::Id {
1226 &self.id
1227 }
1228
1229 fn into_id(self) -> Self::Id {
1230 self.id
1231 }
1232}
1233stripe_types::def_id!(InvoiceId);
1234#[derive(Clone, Eq, PartialEq)]
1235#[non_exhaustive]
1236pub enum InvoiceCollectionMethod {
1237 ChargeAutomatically,
1238 SendInvoice,
1239 Unknown(String),
1241}
1242impl InvoiceCollectionMethod {
1243 pub fn as_str(&self) -> &str {
1244 use InvoiceCollectionMethod::*;
1245 match self {
1246 ChargeAutomatically => "charge_automatically",
1247 SendInvoice => "send_invoice",
1248 Unknown(v) => v,
1249 }
1250 }
1251}
1252
1253impl std::str::FromStr for InvoiceCollectionMethod {
1254 type Err = std::convert::Infallible;
1255 fn from_str(s: &str) -> Result<Self, Self::Err> {
1256 use InvoiceCollectionMethod::*;
1257 match s {
1258 "charge_automatically" => Ok(ChargeAutomatically),
1259 "send_invoice" => Ok(SendInvoice),
1260 v => {
1261 tracing::warn!("Unknown value '{}' for enum '{}'", v, "InvoiceCollectionMethod");
1262 Ok(Unknown(v.to_owned()))
1263 }
1264 }
1265 }
1266}
1267impl std::fmt::Display for InvoiceCollectionMethod {
1268 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1269 f.write_str(self.as_str())
1270 }
1271}
1272
1273#[cfg(not(feature = "redact-generated-debug"))]
1274impl std::fmt::Debug for InvoiceCollectionMethod {
1275 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1276 f.write_str(self.as_str())
1277 }
1278}
1279#[cfg(feature = "redact-generated-debug")]
1280impl std::fmt::Debug for InvoiceCollectionMethod {
1281 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1282 f.debug_struct(stringify!(InvoiceCollectionMethod)).finish_non_exhaustive()
1283 }
1284}
1285impl serde::Serialize for InvoiceCollectionMethod {
1286 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1287 where
1288 S: serde::Serializer,
1289 {
1290 serializer.serialize_str(self.as_str())
1291 }
1292}
1293impl miniserde::Deserialize for InvoiceCollectionMethod {
1294 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
1295 crate::Place::new(out)
1296 }
1297}
1298
1299impl miniserde::de::Visitor for crate::Place<InvoiceCollectionMethod> {
1300 fn string(&mut self, s: &str) -> miniserde::Result<()> {
1301 use std::str::FromStr;
1302 self.out = Some(InvoiceCollectionMethod::from_str(s).expect("infallible"));
1303 Ok(())
1304 }
1305}
1306
1307stripe_types::impl_from_val_with_from_str!(InvoiceCollectionMethod);
1308#[cfg(feature = "deserialize")]
1309impl<'de> serde::Deserialize<'de> for InvoiceCollectionMethod {
1310 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1311 use std::str::FromStr;
1312 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
1313 Ok(Self::from_str(&s).expect("infallible"))
1314 }
1315}
1316#[derive(Clone, Eq, PartialEq)]
1317#[non_exhaustive]
1318pub enum InvoiceStatus {
1319 Draft,
1320 Open,
1321 Paid,
1322 Uncollectible,
1323 Void,
1324 Unknown(String),
1326}
1327impl InvoiceStatus {
1328 pub fn as_str(&self) -> &str {
1329 use InvoiceStatus::*;
1330 match self {
1331 Draft => "draft",
1332 Open => "open",
1333 Paid => "paid",
1334 Uncollectible => "uncollectible",
1335 Void => "void",
1336 Unknown(v) => v,
1337 }
1338 }
1339}
1340
1341impl std::str::FromStr for InvoiceStatus {
1342 type Err = std::convert::Infallible;
1343 fn from_str(s: &str) -> Result<Self, Self::Err> {
1344 use InvoiceStatus::*;
1345 match s {
1346 "draft" => Ok(Draft),
1347 "open" => Ok(Open),
1348 "paid" => Ok(Paid),
1349 "uncollectible" => Ok(Uncollectible),
1350 "void" => Ok(Void),
1351 v => {
1352 tracing::warn!("Unknown value '{}' for enum '{}'", v, "InvoiceStatus");
1353 Ok(Unknown(v.to_owned()))
1354 }
1355 }
1356 }
1357}
1358impl std::fmt::Display for InvoiceStatus {
1359 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1360 f.write_str(self.as_str())
1361 }
1362}
1363
1364#[cfg(not(feature = "redact-generated-debug"))]
1365impl std::fmt::Debug for InvoiceStatus {
1366 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1367 f.write_str(self.as_str())
1368 }
1369}
1370#[cfg(feature = "redact-generated-debug")]
1371impl std::fmt::Debug for InvoiceStatus {
1372 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1373 f.debug_struct(stringify!(InvoiceStatus)).finish_non_exhaustive()
1374 }
1375}
1376impl serde::Serialize for InvoiceStatus {
1377 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1378 where
1379 S: serde::Serializer,
1380 {
1381 serializer.serialize_str(self.as_str())
1382 }
1383}
1384impl miniserde::Deserialize for InvoiceStatus {
1385 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
1386 crate::Place::new(out)
1387 }
1388}
1389
1390impl miniserde::de::Visitor for crate::Place<InvoiceStatus> {
1391 fn string(&mut self, s: &str) -> miniserde::Result<()> {
1392 use std::str::FromStr;
1393 self.out = Some(InvoiceStatus::from_str(s).expect("infallible"));
1394 Ok(())
1395 }
1396}
1397
1398stripe_types::impl_from_val_with_from_str!(InvoiceStatus);
1399#[cfg(feature = "deserialize")]
1400impl<'de> serde::Deserialize<'de> for InvoiceStatus {
1401 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1402 use std::str::FromStr;
1403 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
1404 Ok(Self::from_str(&s).expect("infallible"))
1405 }
1406}