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